mysql 遇到的一些问题

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

不能先将select出表中的某些值,再update这个表(在同一语句中)

原来的sql:

UPDATE sys_user set   pull_path =
(SELECT pull_path FROM sys_user u WHERE username = 'lanl3087@sbd.gx.csg.cn')

WHERE username ='admin'

  修改为:

UPDATE sys_user SET pull_path =   
(  
  SELECT ub.pull_path FROM  
        (  
             SELECT ua.pull_path FROM sys_user ua WHERE ua.username = 'lanl3087@sbd.gx.csg.cn'
        ) ub  
)  

WHERE username ='admin'

  

posted @ 2020-04-01 15:40  AlexZS  Views(120)  Comments(0Edit  收藏  举报