即使存在标点符号,也可以使用MySQL LIKE运算符进行匹配。让我们首先创建一个表-
create table DemoTable -> ( -> Comments varchar(20) -> );
使用插入命令在表中插入一些记录-
insert into DemoTable values('Good,Morning'); insert into DemoTable values('Nice'); insert into DemoTable values('good,bye!');
使用select语句显示表中的所有记录-
select *from DemoTable;
这将产生以下输出-
+--------------+ | Comments | +--------------+ | Good,Morning | | Nice | | good,bye! | +--------------+ 3 rows in set (0.00 sec)
以下是即使存在标点符号也要匹配的查询-
select *from DemoTable where Comments like '%good%';
这将产生以下输出-
+--------------+ | Comments | +--------------+ | Good,Morning | | good,bye! | +--------------+ 2 rows in set (0.00 sec)