当前位置:网站首页>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
边栏推荐
- What is the essence of cloud database? Explore the core value of Huawei cloud database
- Dongge ate grapes when he ate an algorithm problem!
- SQL server attached database access denial resolution summary
- Traditional purchasing mode has changed! How to innovate automobile purchasing function?
- 团灭 LeetCode 打家劫舍 问题
- [best practice] learn how eolinker helps Telecommuting
- [最佳实践]了解 Eolinker 如何助力远程办公
- 迅为IMX6ULL开发板C程序调用shell
- Modify the files in the jar package
- Installation and deployment of Flink
猜你喜欢

Realization of commodity backstage system

Nine kinds of distributed primary key ID generation schemes of sub database and sub table are quite comprehensive

How to use RTSP streaming component easypusher to push MP4 files to easydarwin open source platform?

More than 60 technical executives gathered in Songshan Lake, and the first phase of Huawei cloud core partner developer training camp was successfully concluded

AQS源码深入分析之条件队列

SQL server attached database access denial resolution summary

JS深拷贝

From master of Engineering Physics of Tsinghua University to open source entrepreneur of cloud computing

Mac无法连接到App Store并提示需要连接网络怎么办?

刚毕业都会迷茫,我经过7年总结,送给程序员的你们7点建议
随机推荐
How to carry out modular power operation efficiently
毕业即失业?大学生如何分配学习时间比例,拥有完整计算机知识体系?
Overseas warehouses witness the vigorous development of cross border e-commerce between China and Europe
C console calls ffmpeg to push MP4 video file to stream media open source service platform easydarwin process
YoMo Codec - Y3的性能评测报告
AQS source code in-depth analysis of conditional queue
Mac无法连接到App Store并提示需要连接网络怎么办?
[最佳实践]了解 Eolinker 如何助力远程办公
40 tips for life that may be useful
Dongge ate grapes when he ate an algorithm problem!
面试官:缓存穿透、缓存雪崩和缓存击穿是什么?
如何运用二分查找算法
How can financial management system help enterprises realize financial automation management?
没有磁盘空间 No space left on device
如何实现后台管理系统的权限路由和权限菜单
R8 compiler: tailoring kotlin libraries and Applications
修改jar包里的文件
正式班D25
LeetCode-378. 有序矩阵中第K小的元素
Chrome扩展程序热更新方案:2.基于双缓存更新功能模块