欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

MySQL:1093错误解决办法

程序员文章站 2022-06-09 17:27:51
...
UPDATE posts SET SpareFlag=0 WHERE Id IN(
	SELECT Id FROM posts WHERE CloseFlag=0 AND LockFlag=0 GROUP BY PosterUid HAVING COUNT(PosterUid)=1
);

 上面这样的写法,数据库会提示1093错误;正确写法如下:

UPDATE posts SET SpareFlag=0 WHERE Id IN(
  SELECT b.Id FROM (SELECT Id FROM posts WHERE CloseFlag=0 AND LockFlag=0 GROUP BY PosterUid HAVING COUNT(PosterUid)=1) AS b
);

 即,为查询条件建个临时表,这样就解决问题了。