目前网上搜索的删除重复记录,大部分都是where子查询,本人感觉看上去不美观,故亲自手写了一个,如下:

delete from mst_sku
using mst_sku,(
  select distinct max(sys_no) as sys_no, sku_code
  from mst_sku
  group by sku_code
  having count(sku_code)>1
) as t2
where mst_sku.sku_code = t2.sku_code
and mst_sku.sys_no <> t2.sys_no;

经检验,语句正确,这样看上去简洁易懂,现做备忘,

有需要的朋友可以试试。

相关文章:

  • 2022-02-04
  • 2022-01-27
  • 2021-08-31
  • 2021-09-14
  • 2021-09-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-27
  • 2021-07-14
  • 2021-11-23
相关资源
相似解决方案