我有这两个表,我的目的是只显示一个人在某个代码基础上得到的最高分,因此只显示个人的名字,从某个没有行取标记并将其与否从另一个表行,并显示名称,代码,没有
表1
+----+------+------+
| no | code | mark |
+----+------+------+
| 01 | B4 | 90 |
| 02 | B5 | 50 |
| 03 | B4 | 50 |
+----+------+------+
表2
+----+------+------+
| no | name | numb |
+----+------+------+
| 01 | John | NULL |
| 02 | Mike | NULL |
| 03 | Jake | NULL |
+----+------+------+
SELECT table2.no, table2.name, table1.code
FROM table2
INNER JOIN table1
WHERE code LIKE 'B4%'
ORDER BY MAX(mark);
主要问题是,代码与表1中的no之间似乎没有联系。
答案 0 :(得分:1)
我也是SQL的新手,但试试这个:
SELECT table2.no, table2.name, table1.code
FROM table2
INNER JOIN table1
ON table1.no = table2.no
WHERE code LIKE 'B4%'
ORDER BY MAX(mark);