Page is a not externally linkable
- Code, Content, and Presentation
-- Databases
---- Combing multiple statements


LifeinAsia - 11:38 pm on Dec 29, 2012 (gmt 0)


This is where a JOIN is your friend. :)

You could join the first 2 results as follows:
SELECT ur.user_id, uc.contact_id
FROM user_reg ur INNER JOIN user_contacts uc ON ur.user_id=ud.user_id
WHERE ur.year='2012' AND ur.end_date IS NULL

You can join the 3rd result set using the same logic.


Thread source:: http://www.webmasterworld.com/databases_sql_mysql/4531887.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com