I need help with my sql query. My query is:
select * from matricula
and show me this information:
nummatri fechamatri dnialum idnivel idgrado idsecc año
3 2017-12-20 12357890 2 7 14 2018
I want you to show me the description of each id, that is, instead of
2=secundaria
7=primero
14=A
I use this query:
SELECT Distinct m.nummatr,m.fechamat, m.idalumno,
n.descnivel,g.descgrado, s.descsecc
FROM
matricula as m INNER JOIN
nivel AS N ON m.idnivel = n.idnivel INNER JOIN
grado as g ON n.idnivel = g.idnivel INNER JOIN
seccion as s ON n.idnivel = s.idnivel AND g.idgrado = s.idgrado
but it shows me this data:
3 2017-12-20 12357890 Secundaria Cuarto A
3 2017-12-20 12357890 Secundaria Cuarto B
3 2017-12-20 12357890 Secundaria Primero A
3 2017-12-20 12357890 Secundaria Primero B
3 2017-12-20 12357890 Secundaria Quinto A
3 2017-12-20 12357890 Secundaria Quinto B
3 2017-12-20 12357890 Secundaria Segundo A
3 2017-12-20 12357890 Secundaria Segundo B
3 2017-12-20 12357890 Secundaria Tercero A
3 2017-12-20 12357890 Secundaria Tercero B
What would be the correct query to show me what I want?