select o.* from t_outbook o, t_book b where (','+rtrim(o.bookid)+',') like '%,'+rtrim(b.id)+',%'
select o.* from t_outbook o, t_book b where charindex(','+rtrim(b.id)+',',','+rtrim(o.bookid)+',')>0 and b.bookname='xml'
select distinct t1.* from t_outbook t1 left join t_book t2 on t1.bookid = cast(t2.id as varchar) or t1.bookid like cast(t2.id as varchar) + ',%' or t1.bookid like '%,' + cast(t2.id as varchar) where t2.bookname = 'xml'
select * from t_outbook where charindex((select cast(id as varchar(10)) from t_book where bookname='xml'),bookid)>0
o.*
from
t_outbook o,
t_book b
where
(','+rtrim(o.bookid)+',') like '%,'+rtrim(b.id)+',%'
o.*
from
t_outbook o,
t_book b
where
charindex(','+rtrim(b.id)+',',','+rtrim(o.bookid)+',')>0
and
b.bookname='xml'
from t_outbook t1 left join t_book t2 on
t1.bookid = cast(t2.id as varchar) or
t1.bookid like cast(t2.id as varchar) + ',%' or
t1.bookid like '%,' + cast(t2.id as varchar)
where t2.bookname = 'xml'
where
charindex((select cast(id as varchar(10)) from t_book where bookname='xml'),bookid)>0
望 子陌老大能详细讲解一下这句话,小弟不是很明白 charindex(','+rtrim(b.id)+',',','+rtrim(o.bookid)+',')>0