dflow Posted August 16, 2011 Share Posted August 16, 2011 #1064 - 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 'LIMIT 0, 30' at line 5 SELECT * FROM `apartments` WHERE city_id IN ( 3, 4, 5 ) AND DESC ='' and RIGHT(ID,(SELECT * FROM apartments WHERE ID IN (2,3)) [code] Quote Link to comment https://forums.phpfreaks.com/topic/244934-help-with-query-syntax/ Share on other sites More sharing options...
fenway Posted August 16, 2011 Share Posted August 16, 2011 DESC is a reserved keyword. What are you trying to do with that subselect???? Quote Link to comment https://forums.phpfreaks.com/topic/244934-help-with-query-syntax/#findComment-1258156 Share on other sites More sharing options...
Maq Posted August 16, 2011 Share Posted August 16, 2011 I don't see a LIMIT clause in your query either. Quote Link to comment https://forums.phpfreaks.com/topic/244934-help-with-query-syntax/#findComment-1258159 Share on other sites More sharing options...
dflow Posted August 17, 2011 Author Share Posted August 17, 2011 HI the DESC was a typo for Description i want to get a query that results in ID's ending with specific INTs (1,4,6,7) etc Quote Link to comment https://forums.phpfreaks.com/topic/244934-help-with-query-syntax/#findComment-1258507 Share on other sites More sharing options...
Muddy_Funster Posted August 17, 2011 Share Posted August 17, 2011 couldn't you just do : SELECT * FROM apartments WHERE city_id IN ( 3, 4, 5 ) AND DESCRIPTION ='' AND ID IN (SELECT ID FROM apartments WHERE ID LIKE '%1' OR ID LIKE '%4' OR ID LIKE '%6' OR ID LIKE '%7') Still don't see where your LIMIT statement is that is mentioned in the actual error though. Quote Link to comment https://forums.phpfreaks.com/topic/244934-help-with-query-syntax/#findComment-1258512 Share on other sites More sharing options...
dflow Posted August 17, 2011 Author Share Posted August 17, 2011 couldn't you just do : SELECT * FROM apartments WHERE city_id IN ( 3, 4, 5 ) AND DESCRIPTION ='' AND ID IN (SELECT ID FROM apartments WHERE ID LIKE '%1' OR ID LIKE '%4' OR ID LIKE '%6' OR ID LIKE '%7') Still don't see where your LIMIT statement is that is mentioned in the actual error though. THANKS Quote Link to comment https://forums.phpfreaks.com/topic/244934-help-with-query-syntax/#findComment-1258514 Share on other sites More sharing options...
fenway Posted August 17, 2011 Share Posted August 17, 2011 IDs "ending" in specific values? Why??? Quote Link to comment https://forums.phpfreaks.com/topic/244934-help-with-query-syntax/#findComment-1258518 Share on other sites More sharing options...
dflow Posted August 17, 2011 Author Share Posted August 17, 2011 IDs "ending" in specific values? Why??? but that would be telling the secret Quote Link to comment https://forums.phpfreaks.com/topic/244934-help-with-query-syntax/#findComment-1258524 Share on other sites More sharing options...
fenway Posted August 17, 2011 Share Posted August 17, 2011 IDs "ending" in specific values? Why??? but that would be telling the secret *shudder* Quote Link to comment https://forums.phpfreaks.com/topic/244934-help-with-query-syntax/#findComment-1258525 Share on other sites More sharing options...
mikosiko Posted August 17, 2011 Share Posted August 17, 2011 couldn't you just do : SELECT * FROM apartments WHERE city_id IN ( 3, 4, 5 ) AND DESCRIPTION ='' AND ID IN (SELECT ID FROM apartments WHERE ID LIKE '%1' OR ID LIKE '%4' OR ID LIKE '%6' OR ID LIKE '%7') Still don't see where your LIMIT statement is that is mentioned in the actual error though. +1 to fenway *shudder* ... but anyway......a subselect to do that?.... why if RIGHT() also exist Quote Link to comment https://forums.phpfreaks.com/topic/244934-help-with-query-syntax/#findComment-1258580 Share on other sites More sharing options...
Maq Posted August 17, 2011 Share Posted August 17, 2011 Typos, secrets, and apparently not the "real" query... Post the entire query exactly how you have it. You're missing a terminating parenthesis: (ID,(SELECT * FROM apartments WHERE ID IN (2,3)) Quote Link to comment https://forums.phpfreaks.com/topic/244934-help-with-query-syntax/#findComment-1258596 Share on other sites More sharing options...
dflow Posted August 18, 2011 Author Share Posted August 18, 2011 Typos, secrets, and apparently not the "real" query... Post the entire query exactly how you have it. You're missing a terminating parenthesis: (ID,(SELECT * FROM apartments WHERE ID IN (2,3)) //this is what I started off with SELECT * FROM `apartments` WHERE city_id IN ( 3, 4, 5 ) AND Description ='' and RIGHT(ID,(SELECT * FROM apartments WHERE ID IN (2,3)) Quote Link to comment https://forums.phpfreaks.com/topic/244934-help-with-query-syntax/#findComment-1258996 Share on other sites More sharing options...
fenway Posted August 18, 2011 Share Posted August 18, 2011 Like I said before, you can't use * in RIGHT() like that. Quote Link to comment https://forums.phpfreaks.com/topic/244934-help-with-query-syntax/#findComment-1259079 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.