mysql同表条件更新

mobile表结构如上:

实现根据color排序,取出top20,然后更新level为M

具体sql如下:

update mobile set
level=( SELECT "M" from (select id from mobile order by color limit 20) as m where mobile.id=id )

相关文章:

  • 2021-10-09
  • 2022-12-23
  • 2021-08-10
  • 2021-11-09
  • 2021-07-04
  • 2022-12-23
  • 2021-05-15
  • 2022-12-23
猜你喜欢
  • 2021-07-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-19
  • 2021-11-07
相关资源
相似解决方案