Jump to content

Comparing results and only printing NONE duplicates


~mrwizard~

Recommended Posts

I know this may seem trival, but I have been stuck trying to figure this out.

 

I have two mysql result queries that I am trying to compare to each other and then only display the ones that do not match each other.

 

$result202 = mysql_query("SELECT * FROM (SELECT * FROM scheduledjobs WHERE propid='$propid201' AND departclean='ON' AND date<'$workdate' ORDER BY date DESC) AS foo GROUP BY propid");

 

while ($row202 = mysql_fetch_array($result202))

{

$propid202 = $row202['propid'];

$lastdate202 = $row202['date'];

 

if($lastdate202<=$lastdepart){

/*echo "$propid202 - These are just departures with a last date of $lastdate202<br>";*/

 

$result203 = mysql_query("SELECT * FROM (SELECT * FROM scheduledjobs WHERE propid='$propid202' AND arrivalchk='ON' AND date BETWEEN '$lastdepart' AND '$workdate' ORDER BY date DESC) AS foo GROUP BY propid");

 

while ($row203 = mysql_fetch_array($result203))

{

$propid203 = $row203['propid'];

$lastdate203 = $row203['date'];

echo "$propid202 - These are the departures with arrivals within $lastdepart and $workdate<br>";

}

 

That is the code thus far and each query gives me the result that I am looking for. I am trying to compare the $propid202 and $propid203 to one another and only print the $propid202 results that do not match the $propid203 results.

 

Any help would be much appreciated.

do don't need to change the font colour for code you should use the code tags

 

$result202 = mysql_query("SELECT * FROM (SELECT * FROM scheduledjobs WHERE propid='$propid201' AND departclean='ON' AND date<'$workdate' ORDER BY date DESC) AS foo GROUP BY propid");

while ($row202 = mysql_fetch_array($result202))
{
$propid202 = $row202['propid'];
$lastdate202 = $row202['date'];

if($lastdate202<=$lastdepart){
/*echo "$propid202 - These are just departures with a last date of $lastdate202<br>";*/

$result203 = mysql_query("SELECT * FROM (SELECT * FROM scheduledjobs WHERE propid='$propid202' AND arrivalchk='ON' AND date BETWEEN '$lastdepart' AND '$workdate' ORDER BY date DESC) AS foo GROUP BY propid");

while ($row203 = mysql_fetch_array($result203))
{
$propid203 = $row203['propid'];
$lastdate203 = $row203['date'];
echo "$propid202 - These are the departures with arrivals within $lastdepart and $workdate<br>";
}

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.