咸咸海风

https://github.com/xianxianhaifeng

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: :: :: 管理 ::

一、单表中数据去重

将重复的:user_code,user_name 的记录去掉  

delete * 
from  user
WHERE  del_flag = '0'  
and id NOT IN (
        SELECT MIN(id) AS id
        FROM  user
        where del_flag = '0'
        GROUP BY  user_code,user_name
  ) 
) 

原数据:
xxx, 小三,123123,123123,123,123,123
xxx, 小五,213123,12313,1232,123,234
xxx, 小六,123123,123123,123,123,123
xxx, 小三,123123,123123,123,123,123
xxx, 小六,123123,123123,123,123,123

结果:
xxx, 小三,123123,123123,123,123,123
xxx, 小五,213123,12313,1232,123,234
xxx, 小六,123123,123123,123,123,123





posted on 2022-01-04 14:19  咸咸海风  阅读(37)  评论(0编辑  收藏  举报