Synook Posted August 29, 2007 Share Posted August 29, 2007 Oh whoops the SQL query is correct it was a PHP error - I was sending the query the wrong variable. SorryHi all. I have a SQL Query: SELECT ts2_tutorials.*, AVG(rating_value) AS rating_avg, category_name, user_nameFROM ts2_tutorials, ts2_ratings, ts2_categories, ts2_usersWHERE ts2_tutorials.tutorial_id=ts2_ratings.tutorial_id AND ts2_tutorials.category_id=ts2_categories.category_id AND ts2_tutorials.user_id=ts2_users.user_id AND tutorial_verified=1GROUP BY ts2_tutorials.tutorial_idORDER BY tutorial_id DESC LIMIT 3 But it [was] giving the error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP BY ts2_tutorials.tutorial_id ORDER BY tutorial_id DESC LIMIT 3' at line 7[There is no problem any more ] Link to comment Share on other sites More sharing options...
vijay Posted August 29, 2007 Share Posted August 29, 2007 Hi.. you have to use "ts2_ratings.rating_value" in group by in query..Regards,Vijay Link to comment Share on other sites More sharing options...
Synook Posted August 29, 2007 Author Share Posted August 29, 2007 dw it is working now Link to comment Share on other sites More sharing options...
vijay Posted August 29, 2007 Share Posted August 29, 2007 Hi..May i know what the error..? Link to comment Share on other sites More sharing options...
Synook Posted August 30, 2007 Author Share Posted August 30, 2007 There was no error lol - I had the query, then I echoed the query through cut and paste. however, I was sending the wrong variable ($query instead of $where, but irrelevant) to the query. I realised this, but only changed the query in the echo statement. So the shown query is correct, but it wasn't the query that was being executed Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.