Forum Moderators: coopster

Message Too Old, No Replies

php / mysql learner .

Not even sure how to phrase this question

         

maccas

12:53 pm on Apr 15, 2005 (gmt 0)

10+ Year Member



Hi, I am trying to come to grips with php/mysql but I am a bit stuck. I would normally search for an answer or a bit of code but I don't now how to word my question. Any way I have one query that goes something like:

SELECT * FROM abcd WHERE efgh = $id

$id returns 1,2,3,4... up to about 20

Now I need to query each $id on another table and return the title, description etc for each of these id's. But am a stuck on this, any help appreciated. Cheers.

4string

1:50 pm on Apr 15, 2005 (gmt 0)

10+ Year Member



Sounds like you want to do a JOIN query. That will link your two tables together.

SELECT * FROM table1 LEFT JOIN table2 ON table1.id=table2.id;

You specify the two tables to link (LEFT JOIN) and specify on which fields to link them (ON).

You can look up JOIN syntax in the mySQL manual.

maccas

2:26 pm on Apr 15, 2005 (gmt 0)

10+ Year Member



Excellent 4string works a treat.

dmmh

10:26 pm on Apr 15, 2005 (gmt 0)

10+ Year Member



if you still wonder what its called: relational database design :)