表1:
<form action="/" method="get" onsubmit="return (document.getElementById('search').value.length > 2);">
表2:
PRP_ID | NAME
----------------------
100 | something_100
101 | something_101
102 | something_102
表3:
ADN_ID | NAME
----------------------
11 | thing_11
22 | thing_22
33 | thing_33
这是我的数据库结构。
我想从上一个表中选择ID | ADN_ID | PRP_ID | VALUE
----------------------------------------
1 | 11 | 100 | YES
2 | 22 | 100 | YES
3 | 11 | 101 | NO
4 | 22 | 101 | YES
5 | 33 | 102 | YES
{AD}申请PRP_ID
ADN_ID
和IN(11,22)
应该非常简单,但我不知道该怎么做。
WHERE VALUE = YES
这不会起作用,因为它只检查ADN_ID 11值
答案 0 :(得分:2)
您可以添加having
子句:
SELECT PRP_ID
FROM table3
WHERE ADN_ID IN (11,22) AND VALUE = 'YES'
GROUP BY PRP_ID
HAVING COUNT(DISTINCT ADN_ID) = 2;