日期:2014-05-18 浏览次数:20678 次
select * from tab where Tid like '%3,%'
------解决方案--------------------
access啊、、语法好像不一样哦。。
------解决方案--------------------
sorry,1楼有bug,修正如下,
create table lin (Tid varchar(10)) insert into lin select '1,2,3,5' union all select '2,6,13' union all select '3,7' select * from lin where Tid like '%,3,%' or Tid like '3,%' Tid ---------- 1,2,3,5 3,7 (2 row(s) affected)
------解决方案--------------------
select * from tab where Tid like '%3,%'
--or
select * from tab where charindex ('3,',Tid)>0
自己试下!!
------解决方案--------------------
--ACCESS中貌似是这样的
select * from tablename where Instr(','+Tid+',',',3,')>0
------解决方案--------------------
if OBJECT_ID('tb')is not null
drop table tb
go
create table tb
(Tid varchar(10))
insert into tb
select '1,2,3,5' union all
select '2,6,13' union all
select '2,6,13' union all
select '2,6,13' union all
select '2,6,3' union all
select '3,7'
select * from tb
where Tid like '%,3,%' or Tid like '3,%'or Tid like '%,3'
(6 行受影响)
Tid
----------
1,2,3,5
2,6,3
3,7
(3 行受影响)
------解决方案--------------------
以3结尾的你没考虑到。。
if OBJECT_ID('tb')is not null
drop table tb
go
create table tb
(Tid varchar(10))
insert into tb
select '1,2,3,5' union all
select '2,6,13' union all
select '2,6,13' union all
select '2,6,13' union all
select '2,6,3' union all
select '3,7'
select * from tb
where Tid like '*,3,*' or Tid like '3,*'or Tid like '*,3'
(6 行受影响)
Tid
----------
1,2,3,5
2,6,3
3,7
(3 行受影响)