tagged [join]

Merge two rows in SQL

Merge two rows in SQL Assuming I have a table containing the following information: is there a way I can perform a select on the table to get the following Thanks Edit: Fix field2 name for clarity

31 May at 02:37

MySQL how to join tables on two fields

MySQL how to join tables on two fields I have two tables with `date` and `id` fields. I want to join on both fields. I tried that works, but it is very slow. is there a better way to do this?

8 Dec at 19:18

SQL Server - INNER JOIN WITH DISTINCT

SQL Server - INNER JOIN WITH DISTINCT I am having a hard time doing the following: I want to do a join on ValTbl but only for distinct values.

19 Dec at 20:42

How to concatenate two collections by index in LINQ

How to concatenate two collections by index in LINQ What could be a LINQ equivalent to the following code? ``` string[] values = { "1", "hello", "true" }; Type[] types = { typeof(int), typeof(string)...

24 Jan at 10:27

How can I join an array of strings but first remove the elements of the array that are empty?

How can I join an array of strings but first remove the elements of the array that are empty? I am using the following: Parts has 7 entries but two of them are the empty string "". How can I first re...

31 Oct at 19:56

How to select all rows which have same value in some column

How to select all rows which have same value in some column I am new to sql so please be kind. Assume i must display all the employee_ids which have the same phone number(Both columns are in the same ...

16 Sep at 18:16

Linq Sub-Select

Linq Sub-Select How do I write a sub-select in LINQ. If I have a list of customers and a list of orders I want all the customers that have no orders. This is my pseudo code attempt:

9 Feb at 11:50

How to inner join tables from different Data Context?

How to inner join tables from different Data Context? I have two tables from two different Data Contexts. Although both tables are from the same database, two separate datacontexts exist. Error messa...

4 Mar at 05:33

C# Outer Apply in LINQ

C# Outer Apply in LINQ How can I achieve Outer Apply in LINQ? I'm having a bit of a problem. Here's the SQL Query I'm using.

10 Jun at 12:39

How can I delete using INNER JOIN with SQL Server?

How can I delete using INNER JOIN with SQL Server? I want to using `INNER JOIN` in . But I get this error: > Msg 156, Level 15, State 1, Line 15 syntax near the 'INNER'. My code:

What is the syntax for an inner join in LINQ to SQL?

What is the syntax for an inner join in LINQ to SQL? I'm writing a LINQ to SQL statement, and I'm after the standard syntax for a normal inner join with an `ON` clause in C#. How do you represent the ...

21 Aug at 10:31

Join vs. sub-query

Join vs. sub-query I am an old-school MySQL user and have always preferred `JOIN` over sub-query. But nowadays everyone uses sub-query, and I hate it; I don't know why. I lack the theoretical knowled...

3 Nov at 18:0

SQL Inner join 2 tables with multiple column conditions and update

SQL Inner join 2 tables with multiple column conditions and update I am using this script, trying to join 2 tables with 3 conditions and update T1: but I encounter: `Incorrect syntax near the keyword ...

3 May at 15:30

How to join multiple collections with $lookup in mongodb

How to join multiple collections with $lookup in mongodb I want to join more than two collections in MongoDB using the aggregate `$lookup`. Is it possible to join? Give me some examples. Here I have t...

21 Feb at 20:53

Joining 2 SQL SELECT result sets into one

Joining 2 SQL SELECT result sets into one I've got 2 select statements, returning data like this: If I do union, I get something like And rows joined. What i need is getting it like this: Joined on da...

19 Jan at 21:28

What is the difference between JOIN and JOIN FETCH when using JPA and Hibernate

What is the difference between JOIN and JOIN FETCH when using JPA and Hibernate Please help me understand where to use a regular JOIN and where a JOIN FETCH. For example, if we have these two queries ...

7 Feb at 09:2

Update statement with inner join on Oracle

Update statement with inner join on Oracle I have a query which works fine in MySQL, but when I run it on Oracle I get the following error: > SQL Error: ORA-00933: SQL command not properly ended 0093...

20 Nov at 09:39

Joins are for lazy people?

Joins are for lazy people? I recently had a discussion with another developer who claimed to me that JOINs (SQL) are useless. This is technically true but he added that using joins is less efficient t...

9 Apr at 08:41

SQL DELETE with INNER JOIN

SQL DELETE with INNER JOIN There are 2 tables, `spawnlist` and `npc`, and I need to delete data from `spawnlsit`. `npc_templateid = n.idTemplate` is the only thing that "connect" the tables. I have tr...

cartesian product in pandas

cartesian product in pandas I have two pandas dataframes: What is the best practice to get their cartesian product (of course without writing it explicitly like me)?

Using left join and inner join in the same query

Using left join and inner join in the same query Below is my query using a left join that works as expected. What I want to do is add another table filter this query ever further but having trouble do...

13 Mar at 15:27

Linq: What is the difference between == and equals in a join?

Linq: What is the difference between == and equals in a join? I always wondered why there's an `equals` keyword in linq joins rather than using the == operator. Instead of ``` Property deadline = (fro...

14 Jul at 07:32

MySQL Multiple Joins in one query?

MySQL Multiple Joins in one query? I have the following query: So I am using an `INNER JOIN` and grabbing the `image_id`. So now, I want to take that image_id and turn it into `images.filename` f

23 Jan at 15:52

How do you perform a left outer join using linq extension methods

How do you perform a left outer join using linq extension methods Assuming I have a left outer join as such: How would I express the same task using extension methods? E.g. ``` Foo.GroupJoin(Bar, f =>...

15 Apr at 08:9

SQL left join vs multiple tables on FROM line?

SQL left join vs multiple tables on FROM line? Most SQL dialects accept both the following queries: Now obviously when you need an outer join, the second syntax is required. But when doing an inner jo...

28 May at 13:11