当前位置:网站首页>sql 筛选查询重复列
sql 筛选查询重复列
2020-11-09 22:26:00 【龘游戏人生龘】
id_cardxx 为 table;id,id_card,phone均为字段
-- 显示重复列 select * from 表名 where 列名 in (select 列名 from 表名 group by 列名 having COUNT(*)>1) order by 列名
select * from file_selection where mash in (select mash from file_selection group by mash having COUNT(*)>1) order by mash
-- 查询重复数据但排除 最小id MIN( id )
SELECT *
FROM
id_cardxx c
WHERE
EXISTS (
SELECT
a.id
FROM
id_cardxx a,
( SELECT id_card, MIN( id ) AS rid FROM id_cardxx GROUP BY id_card HAVING count( 1 ) > 1 ) b
WHERE
a.id_card = b.id_card
AND a.id != b.rid
AND c.id = a.id
)
AND id > 8071
AND phone IS NULL
ORDER BY
c.id_card;
-- 修改则需要将查询出来的数据当作新表在查询一次 及
UPDATE id_cardxx
set 修改字段 = 'xxxx'
WHERE id in ( SELECT....end ) as xx1
-- 完整sql
UPDATE id_cardxx
set source = 'xxxx'
WHERE id in (
SELECT xx1.id FROM
(
SELECT id
FROM
id_cardxx c
WHERE
EXISTS (
SELECT
a.id
FROM
id_cardxx a,
( SELECT id_card, MIN( id ) AS rid FROM id_cardxx GROUP BY id_card HAVING count( 1 ) > 1 ) b
WHERE
a.id_card = b.id_card
AND a.id != b.rid
AND c.id = a.id
)
AND id > 8071
AND phone IS NULL
) as xx1
)
版权声明
本文为[龘游戏人生龘]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/3628379/blog/4710169
边栏推荐
- Quick for imx6ull development board c program call shell
- [graffiti Internet of things footprint] graffiti cloud platform interface description
- Operation! Nested JSON second change dataframe!
- 低功耗蓝牙单芯片为物联网助力
- Leetcode 49 letter heterotopic word grouping
- 剑指offer之打印超过数组一半的数字
- 说说 C# 9 新特性的实际运用
- Postman(一)---功能介绍
- Hand in hand to teach you to use container service tke cluster audit troubleshooting
- 又一道比较运算符相关的面试题让我明白基础很重要
猜你喜欢
Configure ng
技术点5:XML语言
Configure the NZ date picker time selection component of ng zerro
The solution of type interface * * is not known to the mapperregistry
Realization of commodity backstage system
JS deep copy
如何高效进行模幂运算
11.9
The movie theater booking system based on micro Service Framework
【QT】子类化QObject+moveToThread实现多线程
随机推荐
mongodb 源码实现系列 - 网络传输层模块实现三
Rabbitmq installation
The solution of type interface * * is not known to the mapperregistry
运用强大的 PowerBI 桑基图表示复杂运营业务流
【科创人】Rancher江鹏:从清华工程物理学硕士到云计算开源创业者
VsCode之Markdown插件
PLSQL Developer常用设置
From master of Engineering Physics of Tsinghua University to open source entrepreneur of cloud computing
Configure the NZ date picker time selection component of ng zerro
day84:luffy:优惠活动策略&用户认证&购物车商品的勾选/结算
Old system refactoring skills, easy to handle legacy code
Postman(一)---功能介绍
面试官:缓存穿透、缓存雪崩和缓存击穿是什么?
lvgl 库 V7版本相关应用
How to use RTSP streaming component easypusher to push MP4 files to easydarwin open source platform?
Python调用飞书发送消息
Unemployment after graduation? How do college students allocate their study time and have a complete computer knowledge system?
Mongodb source code implementation series network transport layer module implementation 3
AQS源码深入分析之条件队列
Leetcode 49 letter heterotopic word grouping