SQL Update基于另一个表列条件的一个表列

时间:2015-11-19 12:52:00

标签: mysql database

我有下表:

mentor (mentor_id, name, contact, country)
team (team_id, mentor_id, name, status)

我想更新team.status = 'Approved' where team.mentor_id = mentor.mentor_id AND mentor.country = 'ABC';

但上面的查询无效。请帮帮我谢谢。

1 个答案:

答案 0 :(得分:0)

使用join试试这个: -

update mentor m join
       team t
       on m.mentor_id = t.mentor_id
    set t.status = 'Approved' where m.country = 'ABC'