我有2个表格( docs & doc_process ):
文档
id | content | status
------------------------
1 | content 1 | 1
2 | content 2 | 2
doc_process
id | doc_id | user | status
---------------------------
1 | 1 | 1 | 2
2 | 1 | 2 | 2
3 | 1 | 3 | 2
4 | 2 | 1 | 1
5 | 2 | 2 | 2
6 | 2 | 3 | 1
如果所有doc_id = 1
的值均为2
doc_id | status
---------------
1 | 2
doc_id 2
未过滤,因为id = 4
,id = 6
不等于2
答案 0 :(得分:-1)
使用条件聚合
select doc_id
from your_table
group by doc_id
having sum(status <> 2) = 0