我的进口清单如下表所示 import_order pk:import_date ,import_no, product_id
```
import_date | import_no | product_id | supplier_id | purchase_cost | qty |
2018-01-02 | M0001 | p00001 | s00001 | 2500 | 7 |
2018-01-02 | M0001 | p00002 | s00001 | 2700 | 4 |
2018-01-02 | M0001 | p00003 | s00001 | 3500 | 5 |
我想加入下表供应商详细信息
supplier_detail
supplier_id | supplier_name | tel |
s00001 | DevelopGlasses | +11254421478 |
s00002 | Operalise | +11252232547 |
s00003 | Azuing | +11245454478 |
我想查询这样的结果
import_date | import_no| product_id | supplier_id| supplier_name| tel |
2018-01-02 | M0001 | p00001 | s00001 |DevelopGlasses|+11254421478 |
2018-01-02 | M0001 | p00002 | s00001 |DevelopGlasses|+11254421478 |
2018-01-02 | M0001 | p00003 | s00001 |DevelopGlasses|+11254421478 |
这是我的sql
SELECT i.,s. FROM import_order i INNER JOIN supplier_detail s ON i.s_id = s.s_id
结果是
import_date | import_no| product_id | supplier_id| supplier_name| tel |
2018-01-02 | M0001 | p00001 | s00001 |DevelopGlasses|+11254421478 |
2条答案
按热度按时间ht4b089n1#
你需要纠正你的错误
on
条件为fae0ux8s2#
使用左连接、内连接仅选择相关记录