Web Hosting Talk







View Full Version : nested mysql queries using C


Slidey
01-20-2004, 01:03 PM
Hi,

has anyone got any examples of the above?

ive got 2 tables in a database, and im using info from one to refer to the other..

so we select uid from table1, then select * from table2 where uid=uidfromtable1

but the second query doesnt return anything..

really winding me up!

anyone?

cheers

Slidey

Sheps
01-20-2004, 06:31 PM
SELECT * FROM table1 LEFT JOIN table2 ON table1.uid=table2.uid;

Try that, I think that is what you are looking for... If they are both primary keys, then you won't have any duplicates. I tested this out on a few simple tables.

Slidey
01-20-2004, 07:24 PM
i twigged (or a mate did!) that i could combine the two queries, so thats worked now..

tomorrow gotta see about implementing the rest to see if that will work. bit of a wasted day really!

cheers