多表删除

Posted 浅色夏沫

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了多表删除相关的知识,希望对你有一定的参考价值。

删除重复的记录

mysql> SELECT goods_id,goods_name FROM tdb_goods GROUP BY goods_name HAVING coun
t(goods_name) >= 2;
+----------+-----------------------+
| goods_id | goods_name |
+----------+-----------------------+
| 18 | HMZ-T3W 头戴显示设备 |
| 19 | 商务双肩背包 |
+----------+-----------------------+

mysql> DELETE t1 FROM tdb_goods AS t1 LEFT JOIN (SELECT goods_id,goods_name FROM
tdb_goods GROUP BY goods_name HAVING count(goods_name) >= 2) AS t2 ON t1.goods_
name = t2.goods_name WHERE t1.goods_id > t2.goods_id;
Query OK, 2 rows affected (0.05 sec)

 

以上是关于多表删除的主要内容,如果未能解决你的问题,请参考以下文章

MySQL基础入门学习10多表删除

多表修改和多表删除

多表联查时的sql删除语句的写法,即级联删除,将相关联的数据级联删除

mysql多表删除实例

MySQL中多表删除方法(转载)

Oracle 多表联合删除?--转