文、意如
先建立兩個資料表(客戶資料表、訂單資料表)
客戶資料 | ||
cus_pk | cus_name | cus_phone |
1 | john | 0912345678 |
2 | may | 0912345674 |
3 | judy | 0912345234 |
訂單 | ||
order_pk | cus_pk | order_date |
1 | 2 | 2022-12-21 |
2 | 3 | 2022-12-21 |
3 | 1 | 2022-12-21 |
合併
SELECT myorder.order_pk, customers.cus_name, myorder.orderdate FROM myorder INNER JOIN customers ON myorder.cus_pk=customers.cus_pk;
Yiru@Studio - 關於我 - 意如