Topic: Help with a Function
In the sidebar on the home page you can see a list of all jobs in all cities. I have a huge list of cities so I am trying to shorten this list a bit by only showing cities with at least 2 jobs in them.
Here is the function:
public function GetNumberOfJobsInOtherCities()
{
global $db;
$sql = 'SELECT COUNT(id) AS total FROM '.DB_PREFIX.'jobs WHERE is_temp = 0 AND is_active = 1 AND city_id IS NULL';
$result = $db->query($sql);
$row = $result->fetch_assoc();
return $row['total'];
}I have tried a lot of things but I not a SQL guru. The following did not work:
$sql = 'SELECT COUNT(id) AS total FROM '.DB_PREFIX.'jobs WHERE is_temp = 0 AND is_active = 1 AND city_id IS NULL GROUP BY id HAVING total > 3';Any ideas guys??