Here are my tables:
table1:
ID | data1 | data2
1 | xxx | xxx
2 | xxx | xxx
table2:
ID | table1_id
20 | 1
21 | 1
25 | 2
26 | 2
table3:
ID | table2_id
30 | 20
31 | 21
32 | 25
33 | 26 <--
I have marked the relevant row by an arrow (table3: ID=33 | table2_id=26)
Now, I want the matching ID with data 1 and data 2 from table 1. In this case: 2
I tried something ...
SELECT t1."ID"
FROM table AS t1
INNER JOIN table2 AS tb2
ON t1."ID" = t2."ID"
INNER JOIN table3 AS t3
ON t2."ID" = 26
... but it returns nothing. Have anybody a working subquery for me :)
t1."ID"and the like would NOT be a valid table/field identifier. it'd bet1.IDonly, without the quotes. You could very well have syntax errors that your containing code is not checking for.t1.Id = t2.table1_idnott2.idfor the first join. For the third, you probably meanon t2.id = t3.table2_idt1."ID"is a standard compliant (valid) column identifier - even in MySQL: sqlfiddle.com/#!2/cdd8e/2