Mysql:You can't specify target table 'c_software' for update in FROM clause
mysql查询更新时遇到:You can't specify target table 'c_software' for update in FROM clause
错误语句:
UPDATE `c_software` SET slinkt=concat(slinkt,'3,')
WHERE sid IN (
SELECT sid FROM `c_software`
WHERE slinkt not like '%32,%');
解决方法:
UPDATE `c_software` SET slinkt=concat(slinkt,'3,')
WHERE sid IN (
SELECT sid FROM (
SELECT sid FROM `c_software`
WHERE slinkt not like '%32,%') as tmp);
做一个临时表,就可以解决了,估计mysql内部有限制;
错误语句:
UPDATE `c_software` SET slinkt=concat(slinkt,'3,')
WHERE sid IN (
SELECT sid FROM `c_software`
WHERE slinkt not like '%32,%');
解决方法:
UPDATE `c_software` SET slinkt=concat(slinkt,'3,')
WHERE sid IN (
SELECT sid FROM (
SELECT sid FROM `c_software`
WHERE slinkt not like '%32,%') as tmp);
做一个临时表,就可以解决了,估计mysql内部有限制;