Forum Moderators: coopster
mysql_query("SELECT code.* FROM code INNER JOIN ratings ON code.id = ratings.codeid WHERE SUM(ratings.rating) >= 50 ORDER BY code.id DESC");
Obviously this won't work because you cant use SUM in the WHERE clause, but you can see what I am trying to do. Any ideas?
[edited by: FiRe at 1:41 pm (utc) on Feb. 23, 2007]
SELECT [b]*[/b] FROM code....
I have a feeling that may be it, but also if you are receiving any errors that would really help.
Add the "or die" statement:
mysql_query('blahblahblah') or die(mysql_error());
By adding the "or die" statement that I have given you, it should let you know which of these it is, and if it's the third one, where to start looking :)
Thanks omoutop but it didn't work, the main problem is because I am not selecting the ratings table until further in the statement and you cant use SUM before FROM (I think) which is why these variations are not going to work...
eelixduppy I have been coding php/mysql apps for 3 years
I wasn't being rude. If you are experiencing an error in your query and you don't know how to fix it, the error from mysql will provide some insight, that's all. If you'd rather screw around with the query blindly, then go ahead, I'm just giving a suggestion. I did not intend to offend you.