phpretard Posted March 24, 2008 Share Posted March 24, 2008 Is it possable to select 2 tables with the same query? I would like to combine the two statements. mysql_query("SELECT * FROM members WHERE CNumber='$CNumber' "); mysql_query("SELECT * FROM readings WHERE CNumber='$CNumber' AND RType='$RType'"); Thank you. Quote Link to comment Share on other sites More sharing options...
soycharliente Posted March 24, 2008 Share Posted March 24, 2008 Is it possable to select 2 tables with the same query? I would like to combine the two statements. mysql_query("SELECT * FROM members WHERE CNumber='$CNumber' "); mysql_query("SELECT * FROM readings WHERE CNumber='$CNumber' AND RType='$RType'"); Thank you. Is CNumber the same thing in both tables? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted March 24, 2008 Share Posted March 24, 2008 Use a JOIN: SELECT * FROM members m, readings r WHERE m.CNumber='$CNumber' AND r.CNumber='$CNumber' AND r.RType='$RType'" Quote Link to comment Share on other sites More sharing options...
phpretard Posted March 24, 2008 Author Share Posted March 24, 2008 Yes it is...but the $RType is only in one of the tables. I need both though. Quote Link to comment Share on other sites More sharing options...
soycharliente Posted March 24, 2008 Share Posted March 24, 2008 SELECT * FROM members m JOIN readings r ON m.CNumber=r.CNumber WHERE r.RType='$RType' That the same thing as yours wild? Quote Link to comment Share on other sites More sharing options...
phpretard Posted March 24, 2008 Author Share Posted March 24, 2008 Thank a million!!! The solved button is still gone?? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.