Jump to content

how to put these 2 queries into 1?


dragon_sa

Recommended Posts

// 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'];

Link to comment
https://forums.phpfreaks.com/topic/224401-how-to-put-these-2-queries-into-1/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.