如果在搜索“ñ”时不希望所有包含“ n”的记录,请使用以下语法-
select *from yourTableName where yourColumnName LIKE '%ñ%' COLLATE utf8_spanish_ci;
让我们首先创建一个表。以下是查询-
mysql> create table NotIncludenDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ClientName varchar(20) -> );
以下是使用insert命令在表中插入一些记录的查询-
mysql> insert into NotIncludenDemo(ClientName) values('John'); mysql> insert into NotIncludenDemo(ClientName) values('Johñ'); mysql> insert into NotIncludenDemo(ClientName) values('Johnñy');
以下是使用select语句显示表中所有记录的查询-
mysql> select *from NotIncludenDemo;
这将产生以下输出-
+----+------------+ | Id | ClientName | +----+------------+ | 1 | John | | 2 | Johñ | | 3 | Johnñy | +----+------------+ 3 rows in set (0.00 sec)
以下是搜索“ñ”的查询-
mysql> select *from NotIncludenDemo where ClientName LIKE '%ñ%' COLLATE utf8_spanish_ci;
这将产生以下输出-
+----+------------+ | Id | ClientName | +----+------------+ | 2 | Johñ | | 3 | Johnñy | +----+------------+ 2 rows in set (0.60 sec)