对于更新数据,update tableName set columnName = ... where columnName2 in(select ....)

如果后面查询和更新的表是同一个表,mysql中是不允许的。

注意:

不能先select出同一表中的某些值,再update这个表(在同一语句中)
解决办法就是:那么建立个临时的表

create tempTable as select columnName2 from tableName

updatae tableName set columnName = strSql where columnName2 in (select columnName2 from tempTable)

相关文章:

  • 2021-07-02
  • 2021-11-15
  • 2021-12-23
  • 2021-05-30
  • 2021-09-17
  • 2021-10-30
  • 2022-01-29
  • 2021-12-07
猜你喜欢
  • 2022-12-23
  • 2021-06-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案