Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A select too smart for me? 1

Status
Not open for further replies.

Sleidia

Technical User
May 4, 2001
1,284
FR
Hello

Here are two tables that have a different structure.

TABLES | FIELDS
table1 : t1_ID, ID_of_t2, f1, f2
table2 : t2_ID, f3, f4

While simply retrieving all the data from table1 without using a WHERE clause, how could I make mySQL retrieve f3 and f4 accordingly to ID_of_t2 being equal to t2_ID?
Is a single query possible in that case?

Until now, I've always done a sub-query inside the loop of the main query which caused as many queries as the number of rows. Not very professional isn't it :(

Although I've read the documentation many times, I doubt that what I want to achieve has anything to do with a Join clause.

Many many thanks to the ones who will have an idea.
Have a nice day.
 
select table1.*, table2.f3,table2.f4
from table1,table2
where table1.ID_of_t2 = table2.t2_ID
 
Hello swampBoogie!

Thank you very much! I have no time to test it right now, but here is a star for you before I go to bed :)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top