Can someone tell me why the following happens and how to fix it?
I have a MySQL query with an ORDER BY clause that looks like this.
ORDER BY (did_voteup-did_votedown) DESC, did_voteup DESC
Therefore, he must order the results by their "effective" rating, as in ..
1st. 10 up - 1 down = 9 effective
2nd. 10 up - 5 down = 5 effective
3rd. 10 up - 7 down = 3 effective
However, as you can see on my page here , he organizes them incorrectly and gives me this.
1st. 1 up - 3 down = -2 effective
2nd. 16 up - 6 down = 10 effective
3rd. 15 up - 5 down = 10 effective
Obviously the 1st line should not be there.
Additional Information..
CREATE TABLE dictionary_definitions (
did_id int(11) unsigned NOT NULL auto_increment,
did_wordid int(11) unsigned NOT NULL default '0',
did_userid int(11) unsigned NOT NULL default '0',
did_status tinyint(1) unsigned NOT NULL default '0',
did_date int(11) NOT NULL default '0',
did_definition text,
did_example text,
did_votecheck int(11) NOT NULL default '0',
did_voteup smallint(5) unsigned NOT NULL default '0',
did_votedown smallint(5) unsigned NOT NULL default '0',
PRIMARY KEY (did_id),
KEY (did_wordid),
KEY (did_userid)
) ENGINE=MyISAM;
SELECT a.did_id, a.did_userid, a.did_definition, a.did_example,
a.did_votecheck, a.did_voteup, a.did_votedown, b.user_name, b.user_extra8
FROM dictionary_definitions AS a LEFT JOIN users AS b ON a.did_userid=b.user_id
WHERE did_wordid=4
ORDER BY (did_voteup-did_votedown) DESC, did_voteup DESC LIMIT 0, 5