tagged [join]

What's the best way to join on the same table twice?

What's the best way to join on the same table twice? This is a little complicated, but I have 2 tables. Let's say the structure is something like this: The tables can be joined based on Table1.PhoneNu...

24 Nov at 15:11

Inner Join: Is this an optimal solution?

Inner Join: Is this an optimal solution? T1: employee [id, salary] T2: department [name, employeeid] (employeeid is a foreign key to T1's id) Problem: Write a query to fetch the name of the department...

11 Dec at 19:46

Left Join With Where Clause

Left Join With Where Clause I need to retrieve all default settings from the settings table but also grab the character setting if exists for x character. But this query is only retrieving those setti...

20 Jan at 20:59

Subselect in a Join - Problem

Subselect in a Join - Problem I've a little Problem with a statement: ``` SELECT p1.Modell_nr, p1.ProductID, p2.count_modlieffarbe_vl, concat(p1.Modell_nr,'_',p1.LiefFarbe) as modfarb_id1 FRO...

28 Feb at 16:41

LINQ to SQL: Multiple joins ON multiple Columns. Is this possible?

LINQ to SQL: Multiple joins ON multiple Columns. Is this possible? A table named `TABLE_1` with the following columns: - `ID`- `ColumnA`- `ColumnB`- `ColumnC` I have SQL query where `TABLE_1` joins on...

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 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

how do you search Right/Left joins?

how do you search Right/Left joins? I am having a problem searching multiple tables ,i have 2 tables tblcourse -courseid -name -status tblenroll -courseid(holds courseid from tblcourse) -studentid let...

7 Jun at 13:13

MySQL: Quick breakdown of the types of joins

MySQL: Quick breakdown of the types of joins I would like a quick breakdown of the types of MySQL joins. I know of these, the rest I am not sure what they mean. - `SELECT * FROM a, b WHERE b.id = a.be...

9 Jun at 14:49

MySQL JOIN with LIMIT 1 on joined table

MySQL JOIN with LIMIT 1 on joined table I want to join two tables, but only get 1 record of table2 per record on table1 For example: This would get me all records in `products`, which is not what I wa...

29 Jul at 21:49

T-SQL: Inner join on a field with 2 values

T-SQL: Inner join on a field with 2 values I have this query on a MS SQL Server 2005: Label_Id is a field containing data like this: I have a custom split Function which returns from a string a table ...

3 Dec at 03: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

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

Inner join of DataTables in C#

Inner join of DataTables in C# Let T1 and T2 are `DataTable`s with following fields I need the joint table How this can be done in C# code in a simple way? Thanks.

10 Feb at 16:22

Joining Results from Two Separate Databases

Joining Results from Two Separate Databases Is it possible to `JOIN` rows from two separate postgres databases? I am working with system with couple databases in one server and sometimes I really need...

22 Feb at 17:17

SQL Server - inner join when updating

SQL Server - inner join when updating I have the below query which does not work. What am I doing wrong? Is this even possible?

6 Mar at 17:11

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

How to perform Join between multiple tables in LINQ lambda

How to perform Join between multiple tables in LINQ lambda I am trying to perform a in LINQ. I have the following classes: And I use the following code (where `product`, `category` and `productcategor...

15 Mar at 13:0

Update Query with INNER JOIN between tables in 2 different databases on 1 server

Update Query with INNER JOIN between tables in 2 different databases on 1 server Need some SQL syntax help :-) Both databases are on the same server ``` db1 = DHE db2 = DHE_Import UPDATE DHE.dbo.tblAc...

27 Mar at 17:24

Can't get c# linq query to compile with joins

Can't get c# linq query to compile with joins Below is a cut down example of some c# code I can't get to compile while doing some linq joins. Does anyone know why this doesn't compile? The error is > ...

30 Mar at 15:34

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

Linq join without equals

Linq join without equals I have a list of rectangles and a list of points. I want to construct a LINQ query that will match the list of points with their corresponding rectangles. Something like this:...

4 May at 20:14

INNER JOIN vs INNER JOIN (SELECT . FROM)

INNER JOIN vs INNER JOIN (SELECT . FROM) Is there any difference in terms of performance between these two versions of the same query? ``` --Version 1 SELECT p.Name, s.OrderQty FROM Product p INNER JO...

20 Jul at 07:3

LINQ to SQL - Left Outer Join with multiple join conditions

LINQ to SQL - Left Outer Join with multiple join conditions I have the following SQL, which I am trying to translate to LINQ: I have seen the typical implementation of the left outer join (ie. `into x...

17 Sep at 15:10

MySQL: How do I join same table multiple times?

MySQL: How do I join same table multiple times? I have two tables `ticket` and `attr`. Table `ticket` has `ticked_id` field and several other fields. Table `attr` has 3 fields: `attr_type` is a fixed ...

24 Sep at 08:56