TRY:
select distinct col1 FROM tableName where
(1=1 and charindex(','''+col2+''',' , ','+ '''bbb'',''aaa''' +','))逻辑和你上面的语句是一样的.
select distinct col1 FROM tableName where
(1=1 and charindex(','''+col2+''',' , ','+ '''bbb'',''aaa''' +','))逻辑和你上面的语句是一样的.
解决方案 »
- 关于备份和还原sqlserver数据库的疑问
- 请教一个SQL语句怎么写???
- 高分求 sql 语句 急!在线等
- 请求高手帮助
- 求,一张表里每个编号产品的成本和、销售额和。
- 急!如何用sql,得到每个不同分类的一条最新记录?
- 我在做备份的时候(主要是做差异备份),是否可以备份到另外一台机器,而不是本地,谢谢!
- 一条SQL语句
- 存储过程中这样写有什么错?set @sql_str="select top 10 * from medication where "+@term_str
- set QUOTED_IDENTIFIER 对中括号无效
- 请问SQL里面有没有为一个列重命名的语句?
- 远程服务器和连接服务器的不同?
select distinct col1 FROM tableName where
(1=1 and charindex(','''+col2+''',' , ','+ '''bbb'',''aaa''' +','))逻辑和你上面的语句是一样的.
不过我要的是这个的格式:declare @a int
set @a=1
select distinct col1 FROM tableName where
col2 in (case when @a=1 then 'bbb','aaa' else '' end)大家想想办法吧
set @a=1
select distinct col1 FROM tableName where
(@a=1 and col2 in ('bbb','aaa')) or (@a<>1 and col2 in(''))
当strbrand为空时,查找所有USCATVLS_1 in 变量txtbrand_txt的记录
其中txtbrand_txt的格式是:'aaa','bb','cc'......
strbrand的格式是 'aaa'请问如何解决呢?................急等
(@a=1 and charindex(','''+col2+''',' , ','+ '''bbb'',''aaa''' +','))
or
(@a<>1 and col2='')