《MySQL常用命令1 / 29 MySQL 常用命令汇总 http://www.database8.com 2011-3-1 2 / 29 Mysql 常用命令 show databases; 显示数据库 create database name; 创建数据库 use databasename; 选择数据库 drop database name 直接删除数据库,不提醒 show tables; 显示表 describe tablename; 显示具体的表结构 select 中加上 disti
刚开始,根据我的想法,这个很简单嘛,上sql语句
delete from zqzrdp where tel in (select min(dpxx_id) from zqzrdp group by tel having count(tel)>1);
执行,报错!!~!~
异常意为:你不能指定目标表的更新在FROM子句。傻了,MySQL 这样写,不行,让人郁闷。
难倒只能分步操作,蛋疼
以下是网友写的,同样是坑爹的代码,我机器上运行不了。
1. 查询需要删除的记录,会保留一条记录。
采用的是下面的方法可删除,假设重复的是test数据库中的title字段 代码如下:create table bak as (select * from test group by title having count(*)=1); insert into bak (select * from test group by title having count(*)>1); truncate table test; insert into test
表结构: mysql> desc demo; +——-+——————+——+—–+———+—————-+ | Field | Type | Null | Key | Default | Extra | +——-+——————+——+—–+———+—————-+ | id | int(11) unsigned | NO | PRI | NULL | auto_increment | | site | varchar(100) | NO | MUL | | | +——-+——————+——+—