Selecting from 2 tables in a single query
Posted
by duder
on Stack Overflow
See other posts from Stack Overflow
or by duder
Published on 2010-06-13T01:40:12Z
Indexed on
2010/06/13
1:42 UTC
Read the original article
Hit count: 313
I have a table that I'm querying for value 43 in the second field and I return the value of the third field
SELECT t1_field3 FROM table1 WHERE t1_field2=43
this returns 19, 39,73
t1_id t1_field2 t1_field3
----- --------- ---------
1 43 19////
2 43 39////
3 43 73////
4 73 43
5 13 40
Then I separately query a second table for additional information
SELECT * FROM table2 WHERE t2_id=t1_field3
t2_id t2_field2 t2_field3
----- --------- ---------
19 value19.2 value19.3
39 value39.2 value39.3
73 value73.2 value73.3
Is there a way I could combine both table1 and table2 in the same query?
© Stack Overflow or respective owner