sql模糊查询
2014-07-15 18:57
330 查看
use pubs
--返回au_lname是以r开头的作者信息
select * from authors
where au_lname like 'r%'
--au_lname的最后一个字母是'n',第一个字母是'M'
--并且au_fname的最后一个字母是'r'
select * from authors
where au_lname like 'm%n' and au_fname like '%r'
--au_lname的第三个字母是e ,au_fname倒数第二个字母是o
select * from authors
where au_lname like '__e%' and au_fname like '%o_'
--au_lname只有四个字母
select * from authors
where au_lname like '____'
--au_lname的最后一个字符是a,b,c,d,e中的任意一个
select * from authors
where au_lname like '%[abcde]'
select * from authors
where au_lname like '%[a,b,c,d,e]'
select * from authors
where au_lname like '%[a-e]'
--address的最后三个字母是数字
select * from authors
where address like '%[0-9][0-9][0-9]'
--address的最后两个字母不是数字
select * from authors
where address like '%[^0-9][^0-9]'
--au_lname的第二个字母不是a,b,c,d,e,f中的任意一个
select * from authors
where au_lname like '_[^a-f]%'
--title的首字母是t,c,b中的任意一个,最后一个字母是s
--notes的最后一个字母不能是n
select * from titles
where title like '[t,c,b]%s' and notes like '%[^n]'
use pubs
--title包含the书籍
select * from titles
where title like '%the%'
--au_lname的第二个字母是"%"
--接在转义符号后面的通配符,会失去通配符的意义
select * from authors
where au_lname like '_a%%' escape 'a'
--查找au_lname是以”[x”开头,以”]”结尾,
select * from authors
where au_lname like 't[x%t]' escape 't'
--对返回的结果排序
select * from authors
order by au_lname desc
select * from titles
order by type desc,price asc
--返回au_lname是以r开头的作者信息
select * from authors
where au_lname like 'r%'
--au_lname的最后一个字母是'n',第一个字母是'M'
--并且au_fname的最后一个字母是'r'
select * from authors
where au_lname like 'm%n' and au_fname like '%r'
--au_lname的第三个字母是e ,au_fname倒数第二个字母是o
select * from authors
where au_lname like '__e%' and au_fname like '%o_'
--au_lname只有四个字母
select * from authors
where au_lname like '____'
--au_lname的最后一个字符是a,b,c,d,e中的任意一个
select * from authors
where au_lname like '%[abcde]'
select * from authors
where au_lname like '%[a,b,c,d,e]'
select * from authors
where au_lname like '%[a-e]'
--address的最后三个字母是数字
select * from authors
where address like '%[0-9][0-9][0-9]'
--address的最后两个字母不是数字
select * from authors
where address like '%[^0-9][^0-9]'
--au_lname的第二个字母不是a,b,c,d,e,f中的任意一个
select * from authors
where au_lname like '_[^a-f]%'
--title的首字母是t,c,b中的任意一个,最后一个字母是s
--notes的最后一个字母不能是n
select * from titles
where title like '[t,c,b]%s' and notes like '%[^n]'
use pubs
--title包含the书籍
select * from titles
where title like '%the%'
--au_lname的第二个字母是"%"
--接在转义符号后面的通配符,会失去通配符的意义
select * from authors
where au_lname like '_a%%' escape 'a'
--查找au_lname是以”[x”开头,以”]”结尾,
select * from authors
where au_lname like 't[x%t]' escape 't'
--对返回的结果排序
select * from authors
order by au_lname desc
select * from titles
order by type desc,price asc
相关文章推荐
- 有关SQL模糊查询
- 有关SQL模糊查询
- SQL的模糊查询
- SQL“多字段模糊匹配关键字查询”[转载]
- 如何在SQL模糊查询中忽略对大小写字符的处理
- 预声明中的模糊查询sql语句(PreparedStatement like sql)怎么写
- 模糊查询SQL
- SQL模糊查询
- SQL语句实现按关健字模糊查询,并按匹配度排序
- 有关SQL模糊查询
- 有关SQL模糊查询
- 在模糊查询中过滤容易引发SQL语句执行异常的符号
- sql中生成查询的模糊匹配字符串
- sql中生成查询的模糊匹配字符串
- 模糊查询SQL语句
- SQL模糊查询
- 有关SQL模糊查询
- ACCESS模糊查询like的解决方法&&SQL查询语句通配符问题
- 有关SQL模糊查询
- [转]SQL模糊查询