Page 1 of 1

joining two queries into one

Posted: Mon Apr 07, 2003 9:16 pm
by theclay7
i have a forum and want to get the data of "Who is the last person updating the message with messageID = $q_id."

I am very new to sql, so I choose to use two mysql query to get the result, however, since I am implementing this in a php called function, how can I join the following two queries into one...

1) select max(q_id) from game_forum where parent_q_id = $q_id OR q_id = $q_id ;

--> parent_q_id = $q_id means that it is a child thread.
--> it then pass the result($LastUpdQID) to the following query.

2) select userID from game_forum where q_id = $LastUpdQID;

how can I joing these two queries into one and get the last updated userID?

Posted: Wed Apr 09, 2003 2:14 am
by bionicdonkey
u can get user UserID in the first query by adding it to the fields selected.
this is because you giving it certain critera to follow. if that makes sense

Posted: Sat Apr 12, 2003 5:14 pm
by kdeveron
Also check out mysql manager (you can search on that name on google). It does a great job of giving you a graphical way of building queries that use multiple joins.