01-02-2008, 01:29 AM
|
#1 (permalink)
|
|
Wizard
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
|
Mysql problem, most likely related to left join
I am making a polling script, I have it able to get the top 3 items voted for. I am trying to left join the item data with the result data with this query
sql Code:
SELECT votes.poll_id AS votes_pollid, COUNT(item_id) AS count, item_id, items.* FROM votes LEFT JOIN items ON votes.id = items.poll_id WHERE votes.poll_id = 1 GROUP BY item_id ORDER BY count DESC LIMIT 3;
(Thanks Wildhoney for the reformatting)
It tels me that votes.poll_id doesn't exist. That is simply not true, I can call votes.poll_id in a separate query and it comes up.
Last edited by Village Idiot : 01-02-2008 at 02:26 AM.
|
|
|
|