我有三个表:category,old和new。
目标:将book_id从旧更新为
表类别有一列:book_id
旧表和新表都有列:id和isbn
我想要实现的目标:
运行MySQL。
答案 0 :(得分:2)
MySQL syntax is a little different that SQL Server or Oracle...
update category cat
inner join old on cat.book_id = old.id
inner join new on old.isbn = new.isbn
set cat.book_id = new.id
答案 1 :(得分:0)
如果您更新类别,则应执行此操作:
update cat
set book_id = new.id
from category cat
join old on cat.book_id = old.id
join new on old.isbn = new.isbn