SQL里怎么用变量实现模糊查询?(难)

2024-12-03 23:39:55
推荐回答(3个)
回答1:

首先要保证变量类型与你的列名类型相同!!

你测试看看!
declare @test varchar(20)

set @test='a'

select * from biao where data2 like '%'+@test+'%'

回答2:

select * from bbsTopic where Ttopic like @name
select * from bbsTopic where Ttopic like '%'+@name+'%'

回答3:

select * from bbsTopic where Ttopic like '%'||@name||'%';