0
有我的兩個表:INNER JOIN在MySQL
表名:FRIENDS
+-------+---------+---------+-------------------+
| id | firstName | lastName | city |
+-------+--------------+------------+-----------+
| 1 | dudi | edri | london |
| 2 | maor | azulay | madrid |
| 3 | batel | azulay | tel aviv |
| 4 | nir | cohen | barcelona |
| 5 | evia | perez | miami |
| 6 | neria | perez | new-york |
| 7 | nevo | kakoun | roma |
+-------+---------+---------+-------------------+
表名:訂單
+-------+---------+---------+-----------------+
| id | firstName | amount | status |
+-------+--------------+----------+-----------+
| 1 | dudi | 5684 | shipped |
| 2 | maor | 4896 | shipped |
| 3 | batel | 2496 | delay |
+-------+--------------+----------+-----------+
我的問題是: 我想沒有訂單的朋友。 答案:
| 4 | nir | cohen | barcelona |
| 5 | evia | perez | miami |
| 6 | neria | perez | new-york |
| 7 | nevo | kakoun | roma |
+-------+---------+---------+-------------------+
我怎麼寫的查詢與內部聯接。 謝謝。
你不應該在'ORDERS'爲外鍵使用您的名字。沒有任何意義 – lad2025
是 - 外鍵應該引用主鍵 – Strawberry
要做內連接的列是:id –