Programmer
Programmer

Reputation: 45

What is wrong with this Replace Into SQL Query?

The SQL query is:

REPLACE INTO `zone` (boundary, level, company_id, country, GeographicalID, city, venue) 
VALUE (
    GeomFromText('Polygon((-121.9453444 37.325689,-121.9454174 37.3256887,
                           -121.9454171 37.3256385,-121.9454164 37.3255364,
                           -121.9453434 37.3255367,-121.9453444 37.325689))'),
    '0', 2, 'US', '6311599', 
    (SELECT id FROM cities WHERE country = 'US' AND name = 'Santa Clara'),
    (SELECT id FROM venues WHERE city = ( 
        SELECT id FROM cities WHERE country = 'US' 
                              AND name = 'Santa Clara') 
        AND name = Westfield Valley Fair 
    )
);

I am getting the following error saying there is an error near the end of the query:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'Valley Fair ))' at line 1

Upvotes: 0

Views: 52

Answers (2)

guru008
guru008

Reputation: 129

You have forget to use inverted comma in name = Westfiled Valley fiar , which should be AND name = 'Westfield Valley Fair'

Upvotes: 0

GrandMasterFlush
GrandMasterFlush

Reputation: 6409

AND name = Westfield Valley Fair )

Should be

AND name = 'Westfield Valley Fair' )

Upvotes: 1

Related Questions