UPDATE department t SET peopleamount = (SELECT COUNT(*) FROM employee e WHERE e.department = t.id)
create table department_temp (部门ID, peopleamount, cnt ) as select 部门ID,peopleamount,count(*) from department group by 部门ID,peopleamountupdate department set peopleamount = (select cnt from department_temp where 部门ID = department.部门ID)
update 部门表 set 部门表.peopleamount = (select count(rowid) from 员工表 where 员工表.department= 部门表.部门ID)
HelloWorld_001(Hello) ( ) 信誉:100 Blog 加为好友 說的有可能啊,
SET peopleamount = (SELECT COUNT(*) FROM employee e WHERE e.department = t.id)
(部门ID,
peopleamount,
cnt
)
as
select 部门ID,peopleamount,count(*) from department group by 部门ID,peopleamountupdate department set peopleamount = (select cnt from department_temp where 部门ID = department.部门ID)
部门表.peopleamount = (select count(rowid) from 员工表 where 员工表.department= 部门表.部门ID)
說的有可能啊,
update还能用子句