like
2024年06月12日
一、认识
二、语法
select field1,field2,……fieldN
from table_name1,table_name2……
where 字段1 like 条件 [and [or]] 条件二……;
三、用法
like
同 =: like
不使用 %
, 效果跟 =
是一样的
select good_name,good_desc,good_price
from good
where good_name like "剑姬";
like
匹配开头: like
关键词%
select good_name,good_desc,good_price
from good
where good_name like "剑%";
like
匹配结尾: like
%
关键词
select good_name,good_desc,good_price
from good
where good_name like "%姬";
like
匹配包含: like
%
关键词%
select good_name,good_desc,good_price
from good
where good_desc like "%对手%";
like
匹配第二个字符: like
_
关键词%
select
event_id
from `base_point`
where
event_id like '_u%';
like
匹配第n个字符: like
____……_
关键词%
select
event_id
from `base_point`
where
event_id like '__y%';
like
匹配倒数第n
个字符: like
%
关键词_
select
event_id
from `base_point`
where
event_id like '%t_';
like
匹配 _
字符: %\_
或者 \_%
或者 %\_%
select
event_id
from `base_point`
where
event_id like '%\_%';