1、批量修改
UPDATE '表名' SET
listdir = CASE aid
WHEN 1000 THEN '/labels/2840'
WHEN 2851 THEN '/labels/2841'
END
WHERE aid IN (2850,2851)
2、查询重复
select keyword,count(*) as count from '表名' group by keyword having count>1;
3、删除重复
DELETE FROM '表名' WHERE keyword IN (SELECT keyword FROM (SELECT keyword FROM '表名' GROUP BY keyword HAVING COUNT(keyword)>1) e)
AND aid NOT IN (SELECT aid FROM (SELECT MIN(aid) AS aid FROM '表名' GROUP BY keyword HAVING COUNT(keyword)>1) t)
以上是编程学习网小编为您介绍的“mysql语句之批量修改、查询重复、删除重复”的全面内容,想了解更多关于 mysql 内容,请继续关注编程基础学习网。
沃梦达教程
本文标题为:mysql语句之批量修改、查询重复、删除重复
基础教程推荐
猜你喜欢
- MySQL触发器的使用和优缺点介绍 2023-08-09
- PHP网页安全认证的实例详解 2024-02-17
- Redis ZSCORE命令 2024-04-06
- Java的MyBatis框架中实现多表连接查询和查询结果分页 2024-02-15
- redis集群搭建以及在SpringBoot中的配置 2024-04-28
- 详解MySQL中timestamp和datetime时区问题导致做DTS遇到的坑 2023-08-09
- select into from和insert into select的使用举例详解 2023-07-26
- 详细聊聊MySQL中的LIMIT语句 2023-08-06
- 一文搞懂MySQL索引特性(清晰明了) 2023-12-28
- Redis 常用命令 2023-09-11