I am trying to do a couple of JOINS in my sql query but have run into a problem. What i need to do is select all fields from the poker_sites table then grab 2 relative fields from networks and if it is available get the average rating from editor_content
The problem i am having is the query is only returning one row when there should be at least three.
Any help would be much appreciated.
here is my SQL
SELECT AVG(editor_content.rating) AS rating, poker_sites.*,
networks.network_name, networks.network_icon FROM poker_sites
LEFT JOIN networks
ON (poker_sites.network_id=networks.network_id)
LEFT JOIN editor_content
ON (poker_sites.site_id=editor_content.assign_id)
WHERE poker_sites.published=1
You need GROUP BY if you want to get multiple results with an aggregate function (in this case AVG).