假设我有一张这样的桌子:
+----------+-----------+-----------+
| name | color_id | shape_id |
+----------+-----------+-----------+
| A | 1 | 1 |
+----------+-----------+-----------+
| B | 2 | 2 |
+----------+-----------+-----------+
| C | 3 | 3 |
+----------+-----------+-----------+
还有另外两个这样的表:
+----------+-------+
| color_id | color |
+----------+-------+
| 1 | R |
+----------+-------+
| 2 | G |
+----------+-------+
| 3 | B |
+----------+-------+
+----------+-------+
| shape_id | shape |
+----------+-------+
| 1 | S |
+----------+-------+
| 2 | T |
+----------+-------+
| 3 | C |
+----------+-------+
我想查询并得到这个结果集:
+----------+-----------+-----------+
| name | color | shape |
+----------+-----------+-----------+
| A | R | S |
+----------+-----------+-----------+
| B | G | T |
+----------+-----------+-----------+
| C | B | C |
+----------+-----------+-----------+
我认为它必须与 JOIN 做一些事情,但我真的不知道如何使它工作。