I'm trying to write this query, but I don't know how to go about it.
Say you have a table with a bunch of listings, with multiple listings per company. You have a status field in the table that is either complete or active.
What I want to do is show ONLY the active companies in the top part of a list, and only the complete companies in the bottom part of the list.
Problem is, some companies have active AND complete listings. Is there a way to check against a previous query? My thought would be to format the code at such:
<?php
//ACTIVE COMPANIES
$query = mysql_query("SELECT * FROM listings WHERE status='active' GROUP BY company");
echo'<ul>';
while($result = mysql_fetch_array($query)) {
echo'<li>'.$result['company'].'</li>';
}
echo'</ul>';
//COMPLETE COMPANIES
$query2 = mysql_query("SELECT * FROM listings WHERE status='complete' GROUP BY company");
echo'<ul>';
while($result2 = mysql_fetch_array($query2)) {
echo'<li>'.$result2['company'].'</li>';
}
echo'</ul>';
?>
I just need to make sure the "active" companies are not duplicated in the "complete" companies. Any help is appreciated! I can't wrap my head around it.