从A表选出数据更新A表是不允许的,需要借助中间临时表操作

update table_A set department_id=1425
where user_id IN(
select id from (
select user_id as id from table_B
left join table_A using(m_id)
where l_id=143969
) as tmp
)


联合两个表查询做更新

UPDATE table_A t1 , (
select d_id,count(*) as cnt from table_B
where h_id = 143969
group by d_id
) t2
SET t1.d_cnt = t2.cnt
WHERE t1.d_id = t2.d_id;
分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]

阅读推荐

服务器相关推荐

开发相关推荐

应用软件推荐