Page 1 of 1

Whats wrong with this Mysql syntax?

Posted: Wed Aug 13, 2008 8:15 am
by recci
I'm trying to do a nested select from the mysql command prompt but i just keep getting hit with a syntax error even though I can see nothing wrong with this query:

SELECT * FROM Resident_Details WHERE GP_ID IN (SELECT GP_ID FROM GP_Details WHERE GP_name = DR Alder);
Any ideas?

cheers

Re: Whats wrong with this Mysql syntax?

Posted: Wed Aug 13, 2008 8:19 am
by EverLearning
Without seeing the error, I can only guess, but I think the error is in missing quote around the name. Try this

Code: Select all

SELECT * FROM Resident_Details WHERE GP_ID IN (SELECT GP_ID FROM GP_Details WHERE GP_name = 'DR Alder');

Re: Whats wrong with this Mysql syntax?

Posted: Wed Aug 13, 2008 8:44 am
by recci
The doesn't work either the error is

ERROR 1064: You have an error in you SQL syntax. Check the manual that corresponds to your mysql server version for the right syntax to use near 'SELECT GP_ID FROM GP_Details WHERE GP_name = 'DR Aulder')' at li

Re: Whats wrong with this Mysql syntax?

Posted: Wed Aug 13, 2008 9:31 am
by EverLearning
What MySql version are you working with?

Re: Whats wrong with this Mysql syntax?

Posted: Wed Aug 13, 2008 9:57 am
by recci
4.0.15 I guess this version does not support nested selects!!!

Re: Whats wrong with this Mysql syntax?

Posted: Wed Aug 13, 2008 10:02 am
by EverLearning
Subqueries are supported with MySql version >= 4.1. You'll have to rewrite your query.