discuz forumグループの同じテーブルでデータを更新

2258 ワード

UPDATE bbs_forum_forum AS ff,(SELECT fid,NAME FROM bbs_forum_forum) AS f SET ff.fup=f.fid



WHERE ff.parent_forum=f.name AND ff.parent_forum IS NOT NULL AND ff.parent_forum <> ''



mysql       

test    

 2   

id int PK 

name varchar(50) 

orgId int FK 



  name            id    ,  orgId=1

update test t set name=(select id from test where orgId=1 and id=t.id)  

           

  :You can't specify target table 't' for update in FROM clause 

      

update test t, (select id,name from test where orgId=1) t2 set t.name=t2.id where t2.id=t.id