select 来自其他人的 id 的最小值 table

select the min value of a id from other table

我想 select 来自其他 table

的 id 的最小值

这是我的 table1

id grades
1 1
2 2
1 3
1 4
2 5

我的table2

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?)

谢谢

SELECT id, table2.name, MIN(table1.grades) grade
FROM table1
JOIN table2 USING (id)
GROUP BY 1,2;