Whats wrong with this Mysql syntax?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
recci
Forum Commoner
Posts: 42
Joined: Tue Jul 29, 2008 10:01 pm

Whats wrong with this Mysql syntax?

Post 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
User avatar
EverLearning
Forum Contributor
Posts: 282
Joined: Sat Feb 23, 2008 3:49 am
Location: Niš, Serbia

Re: Whats wrong with this Mysql syntax?

Post 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');
recci
Forum Commoner
Posts: 42
Joined: Tue Jul 29, 2008 10:01 pm

Re: Whats wrong with this Mysql syntax?

Post 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
User avatar
EverLearning
Forum Contributor
Posts: 282
Joined: Sat Feb 23, 2008 3:49 am
Location: Niš, Serbia

Re: Whats wrong with this Mysql syntax?

Post by EverLearning »

What MySql version are you working with?
recci
Forum Commoner
Posts: 42
Joined: Tue Jul 29, 2008 10:01 pm

Re: Whats wrong with this Mysql syntax?

Post by recci »

4.0.15 I guess this version does not support nested selects!!!
User avatar
EverLearning
Forum Contributor
Posts: 282
Joined: Sat Feb 23, 2008 3:49 am
Location: Niš, Serbia

Re: Whats wrong with this Mysql syntax?

Post by EverLearning »

Subqueries are supported with MySql version >= 4.1. You'll have to rewrite your query.
Post Reply