daxguy Posted February 18, 2013 Share Posted February 18, 2013 I have a search box which uses multiple query depending on the search criteria the following queries work just fine select * from `car_post` where `approve` = '1' and `caru_city` = '2' select * from `car_post` where `approve` = '1' and `caru_make` = '7' and `caru_city` = '2' These queries mentioned above work just fine.. but i want the results to show the latest entries in the table so write the query as select * from `car_post` where `approve` = '1' and `caru_make` = '7' and `caru_city` = '2' ORDER BY caru_id DESC This query works perfectly fine in the SQL client.. it gives the results there... but as i am using it on my page.. by just adding ORDER BY caru_id DESC The query gives the following 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 'DESCLIMIT 0, 10' at line 1 I dont understand if the query is working all fine in the sql client directly why isnt it working here? Quote Link to comment https://forums.phpfreaks.com/topic/274615-a-sql-syntax-error-not-understandable/ Share on other sites More sharing options...
Jessica Posted February 18, 2013 Share Posted February 18, 2013 Because something is adding LIMIT 0, 10 without the space after DESC. Did you actually read the error?? Quote Link to comment https://forums.phpfreaks.com/topic/274615-a-sql-syntax-error-not-understandable/#findComment-1413064 Share on other sites More sharing options...
Barand Posted February 18, 2013 Share Posted February 18, 2013 Numbers in queries should not be quoted where `approve` = 1 and `caru_make` = 7 and `caru_city` = 2 Quote Link to comment https://forums.phpfreaks.com/topic/274615-a-sql-syntax-error-not-understandable/#findComment-1413080 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.