写入值
DROP TABLE IF EXISTS `tp_users`;
CREATE TABLE `tp_users` (
`user_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '表id',
`openid` varchar(100) NOT NULL DEFAULT '' COMMENT '第三方唯一标示',
PRIMARY KEY (`user_id`)
) ENGINE=MyISAM AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 CHECKSUM=1;
/*Data for the table `tp_users` */
insert into `tp_users`(`user_id`,`openid`) values (12,'123');
insert into `tp_users`(`user_id`,`openid`) values (13,'123');
insert into `tp_users`(`user_id`,`openid`) values (15,'235');
insert into `tp_users`(`user_id`,`openid`) values (16,'235');
insert into `tp_users`(`user_id`,`openid`) values (17,'21');
如图
查出重复
SELECT openid,
user_id
FROM tp_users WHERE openid IN(SELECT openid
FROM tp_users
GROUP BY openid
HAVING COUNT(openid) > 1)
如图
转载请注明:谷谷点程序 » mysql查出重复的所有数据