我有
TableName
==============================
ID | A_ID | BLABLA | TIME
-----------------------------------------------
1 | n1 | X | Time
2 | n1 | X | Time
3 | n1 | X | Time
4 | n1 | Y | Time
5 | n1 | Z | Time
6 | n2 | Y | Time
7 | n2 | Y | Time
8 | n2 | Y | Time
9 | n3 | X | Time
10 | n4 | Z | Time
11 | n4 | Z | Time
13 | n5 | | Time
14 | n6 | X | Time
15 | n7 | | Time
16 | n8 | | Time
==================================
我想查询show Table Result并仅使用MySQL查询。
==============================
A_ID | BLABLA
-----------------------------------------------
n1 | X
n1 | Y
n1 | Z
n2 | Y
n3 | X
n4 | Z
n5 |
n6 | X
n7 |
n8 |
==================================
答案 0 :(得分:4)
您需要的只是GROUP BY A_ID, BLABLA
,就像这样:
SELECT A_ID, BLABLA
FROM TableName
GROUP BY A_ID, BLABLA