try:
Select * from table1, table2 where table1.value like '%test%'
and charindex((Select top 1 category from table1 where value like '%test%' ),table2.CATIDs) > 0
Select * from table1, table2 where table1.value like '%test%'
and charindex((Select top 1 category from table1 where value like '%test%' ),table2.CATIDs) > 0
Select * from table1, table2 where table1.value like '%test%' and
charindex(table1.Category,table2.CATIDs)>0
charindex(rtrim(cast(table1.Category as varchar(10))),table2.CATIDs)>0
你要改为: Select * from table1, table2 where table1.value like '%test%' and ','+table2.CATIDs+',' like '%,'+cast(table1.Category as varchar(10))+',%'