sqlÖÐÓÐÒ»±í
tableA
tour_id tour_type
1 1,2,3,4,5,6,16
2 11,23,35,46
3 9,5,3,77,89,12
ÏÖÔÚÈ¡³ötour_typeÖдæÔÚ3µÄ¼Ç¼
½á¹ûÓ¦¸ÃÊÇ
1 1,2,3,4,5,6,16
3 9,5,3,77,89,12
SQL code:
select *
from tb
where charindex(',3,', ','+tour_type+',')>0
SQL code:
select * from tb where ','+tour_type +',' like '%,3,%'
SQL code:
--or
select * from tb where charindex(',3,', ','+tour_type+',')>0
SQL code:
delcare @var varchar(10)
set @var='3'
select * from tableA where charIndex(','+@var+',',','+tour_type+',')>0
SQL code:
select * from tableA
where charindex(',3,',','+tour_type+',')>0
SQL code
Code highlighting produced by Actipro CodeHighlighter (freeware)
htt
ÇëÎÊһϣ¬ÍâÍøÁ½Ì¨SQLSERVERʵÀýÊý¾Ý´«Ê䣬ÓÐûÓвÉÓÃÊý¾ÝѹËõºÍ¼ÓÃÜ¡£Ñ¹Ëõ±ÈÊǶàÉÙ£¬¼ÓÃÜÊÇʲô¼ÓÃÜËã·¨£¿Ïà¹ØÎĵµÄÄÀï¿ÉÒÔÕÒµ½£¿Ð»Ð»
ÎÒÒ²ÏëÖªµÀ£¡¹Ø×¢´ËÌù£¡
¹Ø×¢¡«¡«
Êý¾Ý¿â´óÅ£¶¼ÄÄÈ¥Á˰¡£¿
......