Jump to content

What is wrong with this query?


Synook

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...