如何从一个 SQLite 表的全部内容更新另一个 SQLite 表的子集?
我有一个 SQLite 表,该表必须在特定点之前保持不变。对记录的任何待处理更改都存储在具有相同字段的第二个表中。我想做的,用伪代码来说,是:
for each record U in secondTable
find record R in firstTable, where R.uid = U.uid
replace all fields in record R with those in record U
是否有某种方法可以用 UPDATE 命令来一次性完成此操作?如果有帮助,您可以调用两个表中的字段 uid
、w
、x
、y
和 z
,其中 uid
是唯一的主键。
I have an SQLite table that must remain unchanged until a specific point. Any pending changes to records are stored in a second table, with identical fields. What I want to do, in pseudocode, is:
for each record U in secondTable
find record R in firstTable, where R.uid = U.uid
replace all fields in record R with those in record U
Is there some way to phrase an UPDATE command to do this in one fell swoop? If it helps, you can call the fields in both tables uid
, w
, x
, y
and z
, with uid
being the unique primary key.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果
uid
是您所说的主键,则将起作用。REPLACE
冲突解决方法记录在此处will work if
uid
is the primary key as you say.The
REPLACE
conflict resolution is documented here这:
......应该有效。
This:
...should work.