解决MySQL不能更新同一张表查出来的数据问题
MYSQL个二货,不能先select一张表的数据,然后update这张表,sql如下:
update tab A set A.status=1 where A.id in ( select id from tab where start_time>now() );
解决办法是欺骗这个二货,让他觉得没动过那张表,在外面包装一层。sql如下:
update tab A set A.status=1 where A.id in ( select B.id from( select id from tab where start_time>now() ) B );

浙公网安备 33010602011771号