sql查询

来源:互联网 发布:excel删除重复数据 编辑:程序博客网 时间:2024/06/08 06:28

select newtable.documentId from(

select distinct t4.id as documentId from t_document t4 

left join t_document_record t1 on t4.id = t1.documentId 

left join t_document_issued t2 on t4.id = t2.documentId 

left join t_document_pass t3 on t4.id = t3.documentId 

where t4.c_state <> '0' and t1.c_state = '0' and (t1.fromGroupId = '' or t2.fromGroupId = '' or t2.toGroupId = '' or t3.userId = '' or t4.fromGroupId = '' ) 

order by t4.c_createtime  desc

) newtable

0 0
原创粉丝点击