Use FULL JOIN in MySQL

0

I needed to do a query that returns me in a line the data of a candidate plus the courses to which he applied, being that this data is in a relational table 'tblcandidatoCurso'. After some research I tried to use the FULL JOIN, but it always appears to me a syntax error.

Follow the query I made

SELECT DISTINCT can.idCandidato, cur.idCurso, cur1.idCurso, cur2.idCurso
FROM
tblcandidatura AS can
INNER JOIN tblcandidatocurso AS cur ON cur.idCandidato = can.idCandidato
FULL JOIN tblcandidatocurso AS cur1 ON cur1.idCandidato = can.idCandidato
FULL JOIN tblcandidatocurso AS cur2 ON cur2.idCandidato = can.idCandidato
WHERE cur.ordem = 0
AND cur1. ordem = 1
AND cur2.ordem = 2

The goal was to have something like this:

    
asked by anonymous 14.04.2016 / 15:04

1 answer

1

As @fleuquer-lima said in the comments, you are creating 3 joins with the same table. Your sql should be the same as the question image, the first table links with the second strong> link with third .

SELECT can.idCandidato, cur.idCurso, cur1.idCurso, cur2.idCurso
FROM tblcandidatura AS can
JOIN tblcandidatocurso AS cancur ON cancur.idCandidato = can.idCandidato
JOIN tblcursos AS cur ON cur.idCurso = cancur.idCurso;
    
14.04.2016 / 16:21