Select Column1 From Table Where @Variable Like '%' + Column2 + '%'
似乎并不像我想象的那样工作。有什么建议么?
(模糊的问题)
您是否以错误的方式获取了 Category 和 @Variable:sqlFiddle http://sqlfiddle.com/#!3/630f5/3
create table the_table
(
category varchar(10),
[Date] datetime,
Amount decimal(12, 2)
)
insert into the_table
values
( 'X', '2012-1-1', 10),
( 'X', '2012-1-3', 10),
( 'Y', '2012-1-3', 20),
( 'Y', '2012-1-5', 10)
declare @Variable varchar(10)
set @Variable = 'Y'
Select *
From the_table
--Where @Variable Like '%' + category + '%'
Where category Like '%' + @Variable + '%'
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)