一、多个使用%表示
declare @s varchar(30)
set @s='co%'
select * from sysobjects where (name like @s)
查询结果
code12009058193
code22025058250
二、一个使用_表示
declare @s varchar(30)
set @s='cod_1'
select * from sysobjects where (name like @s)
查询结果
code12009058193
本文演示了如何在SQL查询中使用通配符%和_进行模糊搜索。通过两个实例展示了使用不同通配符匹配字符串的方法,适用于数据库查询场景。
一、多个使用%表示
declare @s varchar(30)
set @s='co%'
select * from sysobjects where (name like @s)
查询结果
code12009058193
code22025058250
二、一个使用_表示
declare @s varchar(30)
set @s='cod_1'
select * from sysobjects where (name like @s)
查询结果
code12009058193
1781
1119
2418
750
432

被折叠的 条评论
为什么被折叠?