[Solved] JOIN ON WITH MAX VALUE MYSQL


If you just want the max score per student you can aggregate the rows before joining:

select s.id_student, u.name, u.role, s.status, u.no_phone, s.exam_status, sc.score
from student s
join user u on u.username = s.id_student
join (
  select Max(score) as score, id_student
    from score
    group id_student
)sc on sc.id_student = s.id_student
where mod(s.id_student, 2) = 0
order by sc.score desc;

Note using short aliases for your tables improves the readability of the query; I guessed at which tables the columns are from – using aliases when joining tables means others, and you, don’t need to guess.

0

solved JOIN ON WITH MAX VALUE MYSQL