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. Link to comment https://forums.phpfreaks.com/topic/97686-select-2-tables/ 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? Link to comment https://forums.phpfreaks.com/topic/97686-select-2-tables/#findComment-499845 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'" Link to comment https://forums.phpfreaks.com/topic/97686-select-2-tables/#findComment-499847 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. Link to comment https://forums.phpfreaks.com/topic/97686-select-2-tables/#findComment-499850 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? Link to comment https://forums.phpfreaks.com/topic/97686-select-2-tables/#findComment-499852 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?? Link to comment https://forums.phpfreaks.com/topic/97686-select-2-tables/#findComment-499854 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.