MySQL help please guys!

Soldato
Joined
26 Jun 2009
Posts
3,023
Location
Sheffield
Hey, I have a pretty complicated statement to write, and I can't fathom it at all.

So far I have:

Code:
SELECT table1.t1ID, table1.t1Name, table1.t1Type, table2.t2Info1, table2.t2Info2
FROM table1 LEFT JOIN table2 ON table1.t1ID = table2.t1ID GROUP BY table1.t1Name
ORDER BY table1.t1Name

Basically I need it to do a GROUP BY select on table one, grouped by the t1Name, to return the t1ID, t1Name and t1Type. Then if the table1.t1id is found in the table2.t1id (a foreign key), to return the corresponding t2Info1 and t2Info2. If these are not found, I want it to return NULL. It also needs a (WHERE table2.info3 = "$id") clause working in somewhere...

I dunno if that'll be clear enough, if not I'll post an example type thing.

Cheers guys!
 
Last edited:
Solved it with the help of another forum, I didn't need a group or anything, I need to use a LEFT OUTER JOIN. :P
 
Back
Top Bottom