当前位置:网站首页>SQL filter query duplicate columns
SQL filter query duplicate columns
2020-11-09 22:26:00 【Game life】
id_cardxx by table;id,id_card,phone Are fields
-- Show repeating Columns select * from Table name where Name in (select Name from Table name group by Name having COUNT(*)>1) order by Name
select * from file_selection where mash in (select mash from file_selection group by mash having COUNT(*)>1) order by mash
-- Query duplicate data but exclude Minimum 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;
-- To modify, you need to query the data as a new table once And
UPDATE id_cardxx
set Modify fields = 'xxxx'
WHERE id in ( SELECT....end ) as xx1
-- complete 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
)
版权声明
本文为[Game life]所创,转载请带上原文链接,感谢
边栏推荐
- How to gracefully prevent switch switching of view UI?
- Open source project, private tool, rapid development
- 毕业即失业?大学生如何分配学习时间比例,拥有完整计算机知识体系?
- [最佳实践]了解 Eolinker 如何助力远程办公
- 开源项目,私活利器,快速开发
- The movie theater booking system based on micro Service Framework
- 磁阻式随机存储器MRAM基本原理
- 会展云技术解读 | 面对突发事故,APP 如何做好崩溃分析与性能监控?
- 配置ng
- Low power Bluetooth single chip helps Internet of things
猜你喜欢
Kubernetes-18:Dashboard安装及使用
配置ng
Traditional purchasing mode has changed! How to innovate automobile purchasing function?
How to upload your avatar with code and add your own copyright information?
东哥吃葡萄时竟然吃出一道算法题!
Application of V7 version of lvgl Library
C + + game development
Error running app:Default Activity not found 解决方法
JS深拷贝
2018中国云厂商TOP5:阿里云、腾讯云、AWS、电信、联通 ...
随机推荐
【QT】子类化QObject+moveToThread实现多线程
How can financial management system help enterprises realize financial automation management?
开源项目,私活利器,快速开发
毕业设计之 ---基于微服务框架的电影院订票系统
PHP - curl copy paste access SMS verification code example
C + + game development
Configure the NZ date picker time selection component of ng zerro
From master of Engineering Physics of Tsinghua University to open source entrepreneur of cloud computing
LeetCode 50 Pow(x,n)
公网IP地址和SSL证书可以提升SEO吗?
How to greatly improve the performance of larravel framework under php7? Install stone!
害怕重构?都怪我太晚和你介绍该如何重构,现在我来了
How to make a set of K reverse linked lists
ERP的权限管理的操作与设计--开源软件诞生24
Quick for imx6ull development board c program call shell
那么当下的行情投资者该怎么办呢? 现在新的投资风口来了!
Apache Hadoop的重要组成
It will be 2021. What is the modern C + + worth learning?
【科创人】Rancher江鹏:从清华工程物理学硕士到云计算开源创业者
Kubernetes-18:Dashboard安装及使用