Mysql更新查询有三个表

时间:2015-07-13 10:42:55

标签: mysql sql

我目前正尝试根据三个表之间的联合编写一个sql语句,并且我不断收到同样的错误。这是我的代码:

UPDATE l SET name=n.title FROM location as l INNER JOIN location_instance as i ON l.lid=i.lid INNER JOIN node as n ON n.nid = i.nid

总共有三个表:[location:(lid,name)],[location_instance(nid,lid)]和[node(nid)]。

很抱歉,如果我的问题与你无关,我仍然是这个领域的初学者。 感谢

2 个答案:

答案 0 :(得分:3)

from

中没有update条款
UPDATE location as l
INNER JOIN location_instance as i
ON l.lid=i.lid 
INNER JOIN node as n 
ON n.nid = i.nid
SET l.name=n.title

答案 1 :(得分:1)

请试试这个:

UPDATE location as l SET name=n.title 
INNER JOIN location_instance as i ON l.lid=i.lid 
INNER JOIN node as n ON n.nid = i.nid