dragon_sa Posted January 14, 2011 Share Posted January 14, 2011 // get working staff from staff table $staffSQL=mysql_query("SELECT * FROM staff WHERE ".$weekday." != 'off' AND onLEAVE='no' AND ACTIVE='yes' ORDER BY staffID ASC"); // get appointments for selected date from appointmen table $existSQL=mysql_query("SELECT * FROM appointment WHERE date='$sqlDATE' AND staffID='$staffID'"); I currently have these 2 queries running in a script with the top one first then a while loop of results for that, then a for loop to list appointment times, then the second query with another while loop for that, the problem with that is when it finds appointments on the same day it runs lists the reults twice, so I want to merge the 2 sql queries together and use the original while loop for the result, how can I join or link these 2 queries into 1 the data i am pulling from each is as follows query 1 $name=$staff['staffNAME']; $avail=$staff[$weekday]; $staffID=$staff['staffID']; query 2 $resSTART=$appointV['dateTIME']; $length=$appointV['totalTIME']; Quote Link to comment https://forums.phpfreaks.com/topic/224401-how-to-put-these-2-queries-into-1/ Share on other sites More sharing options...
fenway Posted January 14, 2011 Share Posted January 14, 2011 You need a JOIN, is all. Quote Link to comment https://forums.phpfreaks.com/topic/224401-how-to-put-these-2-queries-into-1/#findComment-1159448 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.