sql反向查询

--主导语句
select string7 from app_k3flow A where  oFlowModelID=12046 and string7 is not null

--条件语句
(select ActorID from Ts_ActorMembers where (actortype=10 and ObjectID in(select deptid from Ts_User where UserID=10160) or (actortype=20 and ObjectID=10160)))

--合并后查询结果
select distinct flowid, string7 from app_k3flow A,
(select  actorid from Ts_ActorMembers where (actortype=10 and ObjectID in(select deptid from Ts_User where UserID=10160) or (actortype=20 and ObjectID=10160))) temp
 where  oFlowModelID=12046 
 and  (','+a.string7+',' like  '%,'+cast(temp.ActorID  as  varchar(10)) +',%' or isnull(string7,'') ='')

sql反向查询_第1张图片

你可能感兴趣的:(sql,数据库)