# MySQL-Front Dump 2.5
#
# Host: localhost Database: test2
# --------------------------------------------------------
# Server version 4.0.12-max-debug-log
#
# Table structure for table 'ta'
#CREATE TABLE `ta` (
`id` int(3) unsigned NOT NULL default '0',
`name` char(5) default NULL,
KEY `id_name` (`id`,`name`)
) TYPE=MyISAM;#
# Dumping data for table 'ta'
#INSERT INTO `ta` VALUES ("1", "a"),
("1", "a"),
("1", "b"),
("1", "c"),
("2", "a"),
("2", "b"),
("2", "c"),
("3", "a"),
("3", "b"),
("3", "c"),
("3", "c");
mysql> SELECT * FROM `ta`;
+----+------+
| id | name |
+----+------+
| 1 | a |
| 1 | a |
| 1 | b |
| 1 | c |
| 2 | a |
| 2 | b |
| 2 | c |
| 3 | a |
| 3 | b |
| 3 | c |
| 3 | c |
+----+------+
11 rows in set (0.00 sec)mysql> SELECT *,COUNT(*) AS `Times` FROM `ta`
-> GROUP BY `id`,`name` HAVING Times > 1;
+----+------+-------+
| id | name | Times |
+----+------+-------+
| 1 | a | 2 |
| 3 | c | 2 |
+----+------+-------+
2 rows in set (0.00 sec)
#
# Host: localhost Database: test2
# --------------------------------------------------------
# Server version 4.0.12-max-debug-log
#
# Table structure for table 'ta'
#CREATE TABLE `ta` (
`id` int(3) unsigned NOT NULL default '0',
`name` char(5) default NULL,
KEY `id_name` (`id`,`name`)
) TYPE=MyISAM;#
# Dumping data for table 'ta'
#INSERT INTO `ta` VALUES ("1", "a"),
("1", "a"),
("1", "b"),
("1", "c"),
("2", "a"),
("2", "b"),
("2", "c"),
("3", "a"),
("3", "b"),
("3", "c"),
("3", "c");
mysql> SELECT * FROM `ta`;
+----+------+
| id | name |
+----+------+
| 1 | a |
| 1 | a |
| 1 | b |
| 1 | c |
| 2 | a |
| 2 | b |
| 2 | c |
| 3 | a |
| 3 | b |
| 3 | c |
| 3 | c |
+----+------+
11 rows in set (0.00 sec)mysql> SELECT *,COUNT(*) AS `Times` FROM `ta`
-> GROUP BY `id`,`name` HAVING Times > 1;
+----+------+-------+
| id | name | Times |
+----+------+-------+
| 1 | a | 2 |
| 3 | c | 2 |
+----+------+-------+
2 rows in set (0.00 sec)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货