How to join (merge) data frames (inner, outer, left, right)

Given two data frames: df1 = data.frame(CustomerId = c(1:6), Product = c(rep("Toaster", 3), rep("Radio", 3))) df2 = data.frame(CustomerId = c(2, 4, 6), State = c(rep("Alabama", 2), rep("Ohio",...

hql find an entity by collection

I have an Hibernate Entity named User, which has a Set<Book> Book is another Entity having a String bookName; I want to find all Users having an exact list of Books e.g. List<Book> booksList =...

How to do cross join in R?

How can I achieve a cross join in R ? I know that "merge" can do inner join, outer join. But I do not know how to achieve a cross join in R. Thanks

MySQL (Wordpress) - inner join when updating

I'm trying to update the field post-status of any 'new' records where duplicate post_title can be found to 'draft'. The following select query works as expected and shows the records that I want...

How to select parents and children rows in SQL Server

I want to select all itens related to user_id 53 (parents and children) from the following table. It should be: 1, 2, 4, 8, 9. my_table -------------------------------------------- id parent_id...

Losing authenticated token in symfony

I have a problem with authenticating in symfony. Login_check authenticates user in database but after redirection to /dashboard which should be for authenticated user only, it seems that symfony...

LEFT JOIN in LINQ to entities?

I'm trying out LINQ to entities. I have a problem with the following: I want it to do this: SELECT T_Benutzer.BE_User ,T_Benutzer_Benutzergruppen.BEBG_BE FROM T_Benutzer LEFT JOIN...

Find Replace All String Data in a SQL Server Database

I am looking for a script which finds and replaces all fields of type string within a DB with specified text. The script would for example take the following parameters: Search for: null Replace...

Multiple columns in aggregated expression

I've been struggling with an elegant solution for this for a while, and thought I'd finally cracked it but am now getting the error Multiple columns are specified in an aggregated expression...

SQL Server - Derived Table Data Storage

In SQL Server while writing a query, I noticed that the data in inner query which is a derived table when joined with another table is taking long. The keys joined to the outer table is on the...

EXISTS and less than producing different result from NOT EXISTS and greater than

I'm using SQL Server 2014 Express in the AdventureWorks2012 database, working through a T-SQL textbook to learn. I'm doing the following exercise: Delete the rows from the dbo.demoCustomer table...

MySQL: Table alias doesn't work

I want to rewrite this query so it would be working with table and column alias, but I can't get it working. After some research I found that we cannot use table alias in WHERE clause, I tried to...

Select top 10 posts ordered by quantity of votes

I have two tables, one for image records (posts) and the other one is for likes records. So i made an INNER JOIN from one table to another because i needed to select the image and the quantity of...

How to join two tables using JPA Criteria Builder?

I have an sql table called school, and another called student. Every school has an ID, and every student has a "school ID", which is the ID of the school they belong to. Now I want to find all...

How to perform a left join in SQLALchemy?

I have a SQL query which perfroms a series of left joins on a few tables: SELECT <some attributes> FROM table1 t1 INNER JOIN table2 t2 ON attr = 1 AND attr2 = 1 LEFT JOIN table3 t3 ON...

join two json files based on common key with jq utility or alternative way from command line

I have 2 json files with common key and I need to JOIN them with *jq* utility or alternative way from command line As follows: (for example: jq -join -key "id" jsonFile1...

Not sure what is causing sql error 306

I originally had the following query on sql: SELECT PROJECT_TYPE.PROJECT_TYPE_NAME, PROJECT.PROJECT_NAME, STATUS_TYPE.STATUS_TYPE_NAME, COUNT(*) AS Tasks FROM TASK INNER JOIN PROJECT ON...

in SQL, why is this JOIN returning the key column twice?

I'm sorry if this is a stupid question, but I can't seem to get my head around it. I'm fairly new to SQL and this behavior would be strange in R or Pandas or other things that I'm used to...

Oracle SQL EXPLAIN PLAN - full table access

I have a query that joined up with 5 tables, it executed with elapse time about 0.2 seconds to retrieve 36 records from my DB. Attached below is the analysis of explain plan, as you can see full...

Order products by nearest locations

I want to order products by nearest locations after a location is entered in a search form. I use the Google Maps from ACF to assign location to products and the field is called "address". I have...

Form action is downloading the php file instead of running it

For a class I have to create a phishing site that runs on a VM. I am currently working on my PC and running the site as an HTML. I changed the "form action=" "... to form...

Angular 4 Universal Build Throws Memory Limit Error

I am trying to do my big angular 4 app to make universal build but after reaching 90% of process it throws below error Please help me out for this, I also use --max_new_space_size but it doesn't...

SQL Running total group with sum threshold reset

I have the table : PersonID FirstName PersonAge 1 Pras 2 2 Deep 3 3 Test 4 4 Prash 2 5 ser 1 6 df 8 7 ddf 5 8 vvv 4 9 ...

Combining two tables with date ranges into one table

As part of my work with billing telecoms data I scrape data from a variety of sources to build an accurate costing system. Currently one table takes data from the regulatory spreadsheets and...

SQL code error mismatched input 'from' expecting

Hi below is my SQL code and it gives me error and I do not know why. If anyone can help. select time_dif, count(time_dif) as count from ( select datediff(so_so_close_time,date_closed) as...

How can I populate a table when inner join values might be null?

I'm populating a table which is fetching the ids from 2 other tables to display their information, for example, delivery has a Hamburguer and the box, but the user might register the delivery with...

How to solve error "Operator 'getitem' is not supported on this expression" when using case()

I'm trying to convert the following SQL into SQLAlchemy: select t1.id, t1.field_A, max(case when t2.field_B = 1 then t2.field_C end) test_2_field_b_1, max(case when t2.field_B = 2 then...

SQL Query to count number of tickets reserved

I have two tables: Table 1: id title Table 2: id Table_1_id number_of_tickets I need a query to count the number of tickets from table 2 and show: Table_1_id, title,...

Unrecognized name: employees at [9:8]

This is giving me an unrecognized name error. Why? SELECT employees.name AS employee_name, employees.role AS employee_role, departments.name AS department_name FROM ...

How to create a django queryset object for inner join?

I have two tables. class DibbsSpiderDibbsMatchedProductFieldsDuplicate(models.Model): nsn = models.TextField() nsn2 = models.TextField() cage = models.TextField() part_number =...