![]() |
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:
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. |
Hmmm. I don't see any immediate issues standing out. Could you possibly attach your MySQL dump with dummy data so we can emulate and ponder?
I reformatted the SQL if anybody else wishes to have a stab at it. sql Code:
Personal preference really on the formatting! :-) |
Here is the dump, im running mysql 4.1.21
Code:
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; |
Hmm. That works perfectly for me. Perhaps it's an issue in MySQL 4.1?
|
Don't know, I've already given up and built it using multiple queries. It's a shame really, I have to use 3 more now. Il have to switch servers when I have the chance, but that causes hours of downtime.
|
Shouldn't be item_id removed from "GROUP BY" and "SELECT"?. When you try to COUNT item_id, you should list all columns (e.g., votes.poll_id votes_pollid, itmes.* in the GROUP BY (with an exception for item_id). At least it would work in Oracle...
Code:
SELECT |
Took a little tweaking, but this works.
Code:
SELECT |
| All times are GMT. The time now is 02:12 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0