从表中查出符合条件的id,然后更新其对应的记录,查询与更新为同一个表需要用到临时表。
DROP TABLE IF EXISTS `tmp_table`;
CREATE TEMPORARY TABLE tmp_table SELECT * FROM dc_agent_info where agent_top_agentid = 11 and agent_login_status = 0;
update dc_agent_info SET agent_parentid = 11 , agent_p_parentid = 0 , agent_level = 2 where agent_id
IN (select agent_id from tmp_table);
drop table tmp_table;
mysql临时表的使用
最新推荐文章于 2024-06-16 21:26:34 发布