【发布时间】:2022-01-18 21:22:53
【问题描述】:
我想从其他表中选择一个id的最小值
这是我的桌子1
| id | grades |
|---|---|
| 1 | 1 |
| 2 | 2 |
| 1 | 3 |
| 1 | 4 |
| 2 | 5 |
我的桌子2
| id | name |
|---|---|
| 1 | andy |
| 2 | lucy |
| 3 | kevin |
我试过了
select table2.id, name, min(table1.grades) as grade from table1, table2
但它只显示 1 条记录
我的预期
| id | name | grade |
|---|---|---|
| 1 | andy | 1 |
| 2 | lucy | 2 |
| 3 | kevin | 0(or null?) |
谢谢
【问题讨论】: