+ -
当前位置:首页 → 问答吧 → 求助:查询问题 急

求助:查询问题 急

时间:2011-12-28

来源:互联网

有表:tb如下
id(int) name(varchar) statue(varchar)
1 张三 11,12,17
 
如何写以下这样的语句
select * from tb where 11 in (11,12,17)这样的查询语句



作者: hwhtj   发布时间: 2011-12-28

SQL code
select * from tb where 11 in ('11,12,17')

作者: qianjin036a   发布时间: 2011-12-28

SQL code
select * from tb where statue in (11,12,17)

作者: qianjin036a   发布时间: 2011-12-28

SQL code
select * from tb where charindex(',11,',',11,12,17,')>0

作者: fredrickhu   发布时间: 2011-12-28

SQL code
select * from tb where ','+statue+',' like '%,11,%'


11作為參照時

SQL code
select * from tb where ','+statue+',' like '%,'+'11'+',%'

作者: roy_88   发布时间: 2011-12-28

SQL code
select * from tb where charindex(',11,',','+ statue+',')>0

作者: fredrickhu   发布时间: 2011-12-28

select * from tb where charindex(',11,','+statue+',')>0

作者: SSXYC   发布时间: 2011-12-28