~mrwizard~ Posted February 28, 2010 Share Posted February 28, 2010 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. Link to comment https://forums.phpfreaks.com/topic/193607-comparing-results-and-only-printing-none-duplicates/ Share on other sites More sharing options...
Orionsbelter Posted February 28, 2010 Share Posted February 28, 2010 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>"; } Link to comment https://forums.phpfreaks.com/topic/193607-comparing-results-and-only-printing-none-duplicates/#findComment-1019166 Share on other sites More sharing options...
~mrwizard~ Posted February 28, 2010 Author Share Posted February 28, 2010 Sorry about that... I will from now on.. Link to comment https://forums.phpfreaks.com/topic/193607-comparing-results-and-only-printing-none-duplicates/#findComment-1019224 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.