SQLITE3 中的跨表更新 [英] Cross-table UPDATE in SQLITE3
本文介绍了SQLITE3 中的跨表更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在SQL Server
中,我可以这样做:
UPDATE tbl1
SET col2 = tbl2.col2
FROM table1 tbl1
INNER JOIN table2 tbl2
ON tbl1.col1 = tbl2.col1
我没有费心去查看这是否属于任何 SQL 标准的一部分,而且我确信还有其他方法可以做到这一点,但它惊人很有用.
I haven't bothered to look whether this is part of any SQL standard or not, and I'm sure there are other ways to do it, but it is astoundingly useful.
这是我的问题.我需要用 SQLITE3 在 SQL 中做类似的(即,不是宿主语言).可以吗?
Here's my problem. I need to do something similar in SQL (i.e, not a host language) with SQLITE3. Can it be done?
推荐答案
这适用于 sqlite:
This works for sqlite:
UPDATE tbl1 SET col2 = (SELECT col2 FROM tbl2 WHERE tbl2.col1 = tbl1.col1)
这篇关于SQLITE3 中的跨表更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文