like用在where条件语句中
基本用法:
SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern;
通配符%表示0个或任易个字符,[0-9]表示任意数字,[a-z]表示任意小写字母,[A-Z]表示任意大写字母
eg.
- 查找idoxu表,名称(c_name)包含 “i” 的数据
select * from idoxu where c_name like '%i%';
- 查找idoxu表,名称(c_name)以 “i” 开头的数据
select * from idoxu where c_name like 'i%';
- 查找idoxu表,名称(c_name)以“i”结尾 的数据
select * from idoxu where c_name like '%i';
- 查找idoxu表,名称(c_name)包含数字的数据
select * from idoxu where c_name like '%[0-9]%';
- 查找idoxu表,名称(c_name)包含小写字母的数据
select * from idoxu where c_name like '%[a-z]%';
- 查找idoxu表,名称(c_name)包含大写字母的数据
select * from idoxu where c_name like '%[A-Z]%';
网友评论