1

我有

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 
==================================

我只想查询显示表结果和使用 MySQL 查询。

==============================
A_ID | BLABLA 
-----------------------------------------------
n1 | X 
n1 | Y 
n1 | Z 
n2 | Y 
n3 | X 
n4 | Z 
n5 | 
n6 | X 
n7 | 
n8 | 
==================================
4

1 回答 1

4

你所需要的只是GROUP BY A_ID, BLABLA,像这样:

SELECT A_ID, BLABLA 
FROM TableName
GROUP BY A_ID, BLABLA 
于 2012-04-23T04:56:06.193 回答