2014-07-13 16:19:11
来 源
中存储网
MySQL
SQL:update forum_membersset is_multi = 1where M_NAME IN(select M_NAME from forum_members)这样写就会报错正确写法 如下UPDATE forum_me
SQL:

  update forum_members

  set is_multi = 1

  where M_NAME IN(

  select M_NAME from forum_members
  )

这样写就会报错

正确写法 如下

  UPDATE forum_members AS A

  INNER JOIN (

  SELECT M_NAME

  FROM forum_members

  ) AS B ON A.M_NAME = B.M_NAME

  SET A.is_multi =1

实际应用

UPDATE recipes AS r1
INNER JOIN (
SELECT id,image
FROM recipes
) AS r2 ON r1.id = r2.id
SET r1.image =concat("main_",r2.image)
 

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。