查询表达式中的语法错误(缺少运算符)?

时间:2011-04-15 20:39:14

标签: sql ms-access

您好,并提前感谢您的帮助。

我收到一个错误:'查询表达式中的语法错误(缺少运算符)'我不知道为什么......任何想法?

这是我的疑问:

 UPDATE 
table1

SET 
table1.country_name = table2.COUNTRY,
table1.city = table2.CITY ,
table1.state = table2.STATE 

FROM
 ( table1 
inner join
table2 
ON
 table2.SITE_ID = table1.SiteID )

where
table1.country_name is null;

2 个答案:

答案 0 :(得分:5)

UPDATE query in Access/Jet SQL中没有FROM子句:

UPDATE table1 INNER JOIN table2 ON table1.SiteID = table2.SITE_ID
SET table1.country_name = table2.COUNTRY,
    table1.city = table2.CITY ,
    table1.state = table2.STATE 
WHERE table1.country_name is null;

答案 1 :(得分:2)

丢失连接表周围的括号。另外,我个人会为table1和table2创建一个别名,并在更新中引用table1别名。像这样:

UPDATE t1
SET 
  t1.country_name = t2.COUNTRY,
  t1.city = t2.CITY,
  t1.state = t2.STATE 
FROM table1 t1 
INNER JOIN table2 t2 ON t2.SITE_ID = t1.SiteID
WHERE
  t1.country_name is null;