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

时间:2017-07-28 16:01:35

标签: mysql sql database

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 
    )
);

我收到以下错误,说明查询结尾附近有错误:

  

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

2 个答案:

答案 0 :(得分:1)

AND name = Westfield Valley Fair )

应该是

AND name = 'Westfield Valley Fair' )

答案 1 :(得分:0)

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