1 2 3 4 5 6 7 8 9 10 11
| SELECT p.id, p.title, p.lat, p.lng, p.type, p.address, p.mg_region,
p.uri, p.phon1, p.phon2, p.fax, p.categorie, p.owner_email, p.description,
COALESCE(SUM(c.total_value) / SUM(c.total_votes), 'undefined') AS moyenne
FROM places p
LEFT OUTER JOIN comments c ON c.id_places = p.id
WHERE p.approved = 1
AND p.mg_region = '$region'
AND p.type = '$type'
GROUP BY p.id, p.title, p.lat, p.lng, p.type, p.address, p.mg_region,
p.uri, p.phon1, p.phon2, p.fax, p.categorie, p.owner_email, p.description, p.`order`
ORDER BY p.`order` |