2016-08-18 39 views
0

当运行查询:与MYSQL更新加入

UPDATE video v,akadam_post a,location l 
SET v.location_id=l.id 
WHERE a.encoding_id=v.id AND l.continentCode=a.loc_continent_code AND 
l.countryCode=a.loc_country_code AND l.regionCode=a.loc_region_code AND 
l.cityCode=a.loc_city_code 

我得到一个语法错误,任何想法?

10:04:02 select id,encoding_id from akadam_post a left join location l on l.continentCode=a.loc_continent_code AND l.countryCode=a.loc_country_code AND l.regionCode=a.loc_region_code AND l.cityCode=a.loc_city_code UPDATE video v,akadam_post a,location l SET v.location_id=l.id WHERE a.encoding_id=v.id AND l.continentCode=a.loc_continent_code AND l.countryCode=a.loc_country_code AND l.regionCode=a.loc_region_code AND l.cityCode=a.loc_city_code Error Code: 1064. 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 'UPDATE video v,akadam_post a,location l SET v.location_id=l.id WHERE a.encoding' at line 3 0.00051 sec 

谢谢!

+0

你从不同的查询聘请了错误? – 1000111

+0

没有什么特别突出。你能分享三个表所涉及的表结构(列名和键列)吗? –

回答

1

的语法是不正确的,它应该作为

update video v 
join akadam_post a on a.encoding_id=v.id 
join location l on l.continentCode=a.loc_continent_code 
and l.countryCode=a.loc_country_code and l.regionCode=a.loc_region_code 
and l.cityCode=a.loc_city_code 
set v.location_id=l.id 
+0

该问题来自MySQLworkbench,使用命令行触发语句解决了问题。我怀疑字符串中有一个隐藏的特殊字符。 –