我有两张桌子。说:
This is table 1
+--------+-----------------------+
| stuff | foreing | foreing2 |
+--------+-----------------------+
| bazzzz | 555 | 666 |
+--------+-----------------------+
This is table 2
+-----------------------+
| id_table | values |
+-----------------------+
| 555 | Foo |
+-----------------------+
| 666 | Bar |
+-----------------------+
我想要的是一个SQL查询,它给我一个包含以下信息的行:
+--------+-----------------------+
| stuff | value1 | value2 |
+--------+-----------------------+
| bazzzz | Foo | Bar |
+--------+-----------------------+
这是我试图做的,但实际上它返回两行,这不是我想要的:
SELECT table1.stuff,
table2.values as value1,
table2.values as value2
WHERE table1.foreing = table2.id_table
OR table1.foreing2 = table2.id_table