0
ID | NAME
-----+-------
n1 | BLACK
n2 | WHITE
n3 | RED
n4 | GREEN
表B
ID | A_ID | BLABLA | TIME
---+---------+---------------+--------
1 | n1 | X | sometime
2 | n1 | X | sometime
3 | n1 | X | sometime
4 | n1 | Y | sometime
5 | n1 | Z | sometime
6 | n2 | Y | sometime
7 | n2 | Y | sometime
8 | n2 | Y | sometime
9 | n3 | X | sometime
10 | n3 | Z | sometime
11 | n3 | Z | sometime
12 | n3 | Z | sometime
我的問題
我想作秀查詢表結果並僅使用MySQL查詢。
表結果
NAME | X | Y | Z
-----------+----------+---------+-----
BLACK | 3 | 1 | 0
WHITE | 0 | 3 | 0
RED | 1 | 0 | 3
GREEN | 0 | 0 | 0
它是固定的,你將只有X,Y,Z值(或結果表中的列) – Saket