如下表结构:
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_userunionselect user_name,phone,status,create_time,update_timefrom t_user;去重的sql如下
select user_name,phone,status,create_time,update_time
from t_userunion select user_name,phone,status,create_time,update_timefrom t_user;结果