(android之sqlite三)sql语句中查询带通配符的数据,如下划线 星号等
# %代表任意多个字符
select * from user where username like '%huxiao';
select * from user where username like 'huxiao%';
select * from user where username like '%huxiao%';
# _代表一个字符
select * from user where username like '_';
select * from user where username like '______';
select * from user where username like 'huxia_';
select * from user where username like 'h_xiao';
# 如果我就真的要查%或者_,怎么办呢?使用escape,转义字符后面的%或_就不作为通配符了,注意前面没有转义字符的%和_仍然起通配符作用
select username from gg_user where username like '%xiao\_%' escape '\';
select username from gg_user where username like '%xiao\%%' escape '\';
通常使用'\'来做转义字符,但是也可以使用其他的符号
posted on 2012-10-27 09:36 狗尾草-大数据收割基 阅读(8660) 评论(0) 编辑 收藏 举报