我有一张桌子:
细节
--------------------------------------------------------
ID | PARENT_ID | DATA_KEY | DATA_VALUE
========================================================
1 | 1 | Guitar | 4
--------------------------------------------------------
2 | 1 | Radio | 2
--------------------------------------------------------
3 | 1 | Tv | 2
--------------------------------------------------------
4 | 1 | Drum Kit | 3
--------------------------------------------------------
5 | 2 | Guitar | 4
--------------------------------------------------------
6 | 2 | Radio | 2
--------------------------------------------------------
7 | 2 | Tv | 2
--------------------------------------------------------
8 | 2 | Drum Kit | 3
--------------------------------------------------------
9 | 3 | Guitar | 1
--------------------------------------------------------
10 | 3 | Radio | 2
--------------------------------------------------------
11 | 3 | Tv | 2
--------------------------------------------------------
12 | 3 | Drum Kit | 3
--------------------------------------------------------
如何在 mysql 中选择满足以下条件的不同 PARENT_ID:
- DATA_KEY = '吉他' 和 DATA_VALUE = '4'
- DATA_KEY = '收音机' 和 DATA_VALUE = '2'
查询的预期输出应该是
-------------
PARENT_ID
=============
1
-------------
2
-------------
因为只有 PARENT_ID 1 和 2 有 'Guitar' = '4' 和 'Radio' = '2'