这个替换成SQL查询有什么问题?

时间:2022-01-09 15:45:19

The SQL query is:

SQL查询是:

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

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:SQL语法中有错误;查看与您的MySQL服务器版本对应的手册,以便在第1行的“Valley Fair”附近使用正确的语法

2 个解决方案

#1


1  

AND name = Westfield Valley Fair )

Should be

应该

AND name = 'Westfield Valley Fair' )

#2


0  

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

你忘记在name = Westfiled Valley fiar中使用倒置逗号,这应该是AND name ='Westfield Valley Fair'

#1


1  

AND name = Westfield Valley Fair )

Should be

应该

AND name = 'Westfield Valley Fair' )

#2


0  

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

你忘记在name = Westfiled Valley fiar中使用倒置逗号,这应该是AND name ='Westfield Valley Fair'