分隔字符,选出需要的行
create table temp_T1( ID int, U1 varchar(100), U2 varchar(100) )insert into temp_T1 select 1,'AA2,BB3,AA,AA4',''insert into temp_T1 select 2,'DD1,DD2',''insert into temp_T1 select 3,'CC1',''insert into temp_T1 select 4,'EE8,AA',''insert into temp_T1 select 5,'XX',''insert into temp_T1 select 6,'','TT'insert into temp_T1 select 7,'CCCC',''insert into temp_T1 select 8,'','AA'insert into temp_T1 select 9,'BXXX',''select * from temp_T1ID U1 U2----------- ---------------------------------------------------------------- ----------------------------------------------------------------1 AA2,BB3,AA,AA4 2 DD1,DD2 3 CC1 4 EE8,AA 5 XX 6 TT7 CCCC 8 AA9 BXXX (9 行受影响)
--漏写分隔符select *from tbwhere ','+u1+',' like '%,AA,%' or ','+u2+',' not like '%,AA,%'