当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 【科创人】Rancher江鹏:从清华工程物理学硕士到云计算开源创业者
- sql 大小写转换,去掉前后空格
- 商品后台系统实现
- The problem of looting by leetcode
- JT Jingtao project
- asp.net core中使用Serilog以及自定义Enricher
- Old system refactoring skills, easy to handle legacy code
- Open source project, private tool, rapid development
- 2020-11-09:谈谈布隆过滤器和布谷鸟过滤器的相同点和不同点?
- The basic principle of MRAM
猜你喜欢
AQS源码深入分析之条件队列
Day84: Luffy: preferential activity strategy & User Authentication & checking / settlement of shopping cart goods
价值超10亿美元的直播系统架构图是什么样子的?
你了解你的服务器吗、你知道服务器的有哪些内幕吗
The problem of looting by leetcode
How to gracefully prevent switch switching of view UI?
手把手教你使用容器服务 TKE 集群审计排查问题
JS deep copy
Do you know your server? Do you know what's inside the server
expect ':' at 0, actual = (JSON转化异常解决)
随机推荐
[最佳实践]了解 Eolinker 如何助力远程办公
What is the architecture of a live broadcast system worth more than $1 billion?
商品后台管理实现分析步骤
函数计算进阶-IP查询工具开发
Gets the property value of a column in the list collection object
ERP的权限管理的操作与设计--开源软件诞生24
Hand in hand to teach you to use container service tke cluster audit troubleshooting
迅为IMX6ULL开发板C程序调用shell
JS深拷贝
PHP - curl copy paste access SMS verification code example
Analysis steps of commodity background management
恒讯科技浅谈:出现服务器宕机的处理方式
LeetCode 50 Pow(x,n)
Win7 + vs2015 + cuda10.2 configuration tensorrt7.0
Unemployment after graduation? How do college students allocate their study time and have a complete computer knowledge system?
技术点5:XML语言
财务管理系统如何帮助企业实现财务自动化管理?
SQL server attached database access denial resolution summary
京淘项目day10
From master of Engineering Physics of Tsinghua University to open source entrepreneur of cloud computing