【发布时间】:2018-04-23 21:17:55
【问题描述】:
Sqlite 更新不支持连接。对于以下示例,
update Employee t0 LEFT join EmployeeDetail t1 on (t1.id=t0.id)
set t0.status=1, t1.salary=t1.salary+10000
where t1.salary < 50000 and t0.status=0
要更新的列属于不同的表,它们在哪里 条款。如果使用子查询拆分成如下两条语句:
update Employee set status=1
where id in (select t0.id from
Employee t0 LEFT join EmployeeDetail t1 on (t1.id=t0.id)
where t1.salary < 50000 and t0.status=0)
update EmployeeDetail set salary=salary+10000
where id in (select t1.id from
Employee t0 LEFT join EmployeeDetail t1 on (t1.id=t0.id)
where t1.salary < 50000 and t0.status=0)
执行一个语句会影响另一个语句,因为它会影响 where 子句 限制。
Sqlite 数据库如何解决这个问题?
【问题讨论】:
-
status在哪个表中?两者都有。 -
Employee 表中的状态。已更新。
标签: sql database sqlite join sql-update