anevins Posted April 4, 2011 Share Posted April 4, 2011 I've got a syntax error with my sql query and I don't know the correct structure. I want to select all from a table 'rating' where the column 'check' is equal to the value 'checked', and I want to order it by the id descending, with a limit of 3. This is the wrong syntax: SELECT * FROM rating WHERE check='checked' ORDER BY rating_id DESC LIMIT 3 Any ideas on the right syntax? Link to comment https://forums.phpfreaks.com/topic/232653-syntax-error/ Share on other sites More sharing options...
kickstart Posted April 4, 2011 Share Posted April 4, 2011 Hi Check is a reserved word, so either change the column name (my preferred solution) or surround it with back tics. SELECT * FROM rating WHERE `check`='checked' ORDER BY rating_id DESC LIMIT 3 All the best Keith Link to comment https://forums.phpfreaks.com/topic/232653-syntax-error/#findComment-1196617 Share on other sites More sharing options...
anevins Posted April 4, 2011 Author Share Posted April 4, 2011 SOLVED Thanks Kickstart Link to comment https://forums.phpfreaks.com/topic/232653-syntax-error/#findComment-1196620 Share on other sites More sharing options...
Maq Posted April 4, 2011 Share Posted April 4, 2011 FYI, here's the list: http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html Link to comment https://forums.phpfreaks.com/topic/232653-syntax-error/#findComment-1196643 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.