mysql中去除两条一摸一样的数据
如下表结构:
CREATE TABLE `t_user` ( `id` int(11) NOT NULL, `user_name` varchar(50) DEFAULT NULL, `phone` varchar(11) DEFAULT NULL, `status` int(11) DEFAULT NULL, `create_time` timestamp NULL DEFAULT NULL, `update_time` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
首先 ,查询sql如下:
select user_name,phone,status,create_time,update_time
from t_user,
select user_name,phone,status,create_time,update_time
from t_user
union
select user_name,phone,status,create_time,update_time
from t_user;
去重的sql如下
select user_name,phone,status,create_time,update_time
from t_user
union
select user_name,phone,status,create_time,update_time
from t_user;
结果