MySql

mysql You can't specify target t

2023-01-08  本文已影响0人  Rinaloving

mysql 不能对同一个语句进行查询又更新

问题

UPDATE `TbBookStock`  SET nState = 2  WHERE pkCode IN ( SELECT pkCode FROM `TbBookStock` WHERE nState = 5 AND DATE_ADD(tOffShelf,INTERVAL '48' HOUR)  <= NOW() )

更新.png

解决

UPDATE `TbBookStock`  SET nState = 2  WHERE pkCode IN ( SELECT pkCode FROM ( SELECT pkCode FROM `TbBookStock` WHERE nState = 5 AND DATE_ADD(tOffShelf,INTERVAL '48' HOUR)  <= NOW()) AS a )

参考文档

上一篇下一篇

猜你喜欢

热点阅读