要仅显示特定的重复记录,请使用MySQL LIKE运算符-
select *from yourTableName where yourColumnName like ‘yourValue’;
让我们首先创建一个表-
mysql> create table DemoTable -> ( -> Name varchar(20) -> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values('John'); mysql> insert into DemoTable values('Chris'); mysql> insert into DemoTable values('John'); mysql> insert into DemoTable values('Bob'); mysql> insert into DemoTable values('Chris');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
这将产生以下输出-
+-------+ | Name | +-------+ | John | | Chris | | John | | Bob | | Chris | +-------+ 5 rows in set (0.00 sec)
这是获取特定重复记录的查询-
mysql> select *from DemoTable where Name like 'John';
这将产生以下输出-
+------+ | Name | +------+ | John | | John | +------+ 2 rows in set (0.03 sec)