Hello
Can anyone see where I am going wrong with this query syntax please?
I have a table called reviews and a table called area2. They are linked where reviews.place and area2.id are the same number. I wish to count how many times each place has been reviewed and then display the 5 with the highest rating, providing they have more than 8 reviews.
If I take the WHERE numRev>'8' bit out, then it works fine.
Error message: supplied argument is not a valid MySQL result resource.
$sql = "SELECT area2.id, ( SELECT COUNT(*) AS numRev FROM reviews WHERE area2.id=reviews.place AND publish=1 GROUP BY area2.id ) AS numRev, ( SELECT ROUND(AVG(rating), 1) AS avgRev FROM reviews WHERE area2.id=reviews.place GROUP BY area2.id ) AS avgRev FROM area2 WHERE numRev>'8' ORDER BY avgRev DESC LIMIT 5";
Thank you!