SQL Server 可代替Like语句的用法
2022-11-12 09:55:51
内容摘要
这篇文章主要为大家详细介绍了SQL Server 可代替Like语句的用法,具有一定的参考价值,可以用来参考一下。
感兴趣sql server 的小伙伴,下面一起跟随512笔记的小编罗X来看看吧。
文章正文
这篇文章主要为大家详细介绍了SQL Server 可代替Like语句的用法,具有一定的参考价值,可以用来参考一下。
感兴趣sql server 的小伙伴,下面一起跟随512笔记的小编罗X来看看吧。SQL代码如下:1 2 3 4 5 6 | <code class = "sql" > --提到Like语句大家都很熟悉,比如查找用户名包含有 "c" 的所有用户, 我们可以用 use mydatabase select * from table1 where username like'%c%" ---- 来自www.512pic.com </code> |
1 2 3 4 5 6 | <code class = "sql" > use mydatabase select * from table1 where charindex( 'c' ,username)>0 ---- 来自www.512pic.com </code> |
1 2 3 4 5 | <code class = "sql" > use mydatabase select * from table1 where charindex( '%' ,username)>0 ---- 来自www.512pic.com </code> |
1 2 3 4 5 6 | <code class = "sql" > use mydatabase select * from table1 where charindex(char(37),username)>0 --ASCII的字符即为% ---- 来自www.512pic.com </code> |
注:关于SQL Server 可代替Like语句的用法的内容就先介绍到这里,更多相关文章的可以留意
代码注释