当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
猜你喜欢
随机推荐
[最佳实践]了解 Eolinker 如何助力远程办公
配置ng
[最佳实践]了解 Eolinker 如何助力远程办公
How to greatly improve the performance of larravel framework under php7? Install stone!
商品后台系统优化
Traditional purchasing mode has changed! How to innovate automobile purchasing function?
Application of EMQ X in Internet of things platform of China Construction Bank
Jingtao project Day10
JS深拷贝
获取List集合对象中某一列属性值
表单验证,为避免全局污染,少定义全局变量写法
必看!RDS 数据库入门一本通(附网盘链接)
动物园[CSP2020]
财务管理系统如何帮助企业实现财务自动化管理?
Analysis steps of commodity background management
Technical point 5: XML language
expect ':' at 0, actual = (JSON转化异常解决)
刚毕业都会迷茫,我经过7年总结,送给程序员的你们7点建议
会展云技术解读 | 面对突发事故,APP 如何做好崩溃分析与性能监控?
The solution of type interface * * is not known to the mapperregistry



