Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This query</p> <pre><code>select utilisateur.nom , cour.c_nom , examen.ex_nom from utilisateur left join etude on utilisateur.id_util=etude.fk_util left join cour on etude.fk_cour=cour.id_cour left join passer on utilisateur.id_util=passer.fk_util left join examen on passer.fk_ex=examen.id_ex; </code></pre> <p>Doesn't take into account the fact that an exam is related to a course. I don't think its necessary to do an outer join for what you are trying to achieve, so try this.</p> <pre><code>select utilisateur.nom , cour.c_nom , examen.ex_nom from utilisateur join etude on utilisateur.id_util=etude.fk_util join cour on etude.fk_cour=cour.id_cour join passer on utilisateur.id_util=passer.fk_util join examen on cour.id_cour = examen.fk_cour; </code></pre> <p>Edit : This was a bit more complicated than it first appeared to me, I've added a new solution below. The first thing I did was add some aliases to the query, there is an issue with doing ansi joins between 3 or more tables if you don't use aliases on certain versions of oracle. Aliases being generally a good thing, I've added them in anyway. I also moved some of the tables into inline views, to make the problem clearer to myself as much as anything. Aside from this tidying up, the only real change I've made is to add this line :- </p> <p>AND paex.id_ex = coex.id_ex </p> <p>I've tested this query against some data that I created as you described, and it seems to do what you want.</p> <pre><code> SELECT ut.id_util ,ut.nom ,coex.c_nom ,paex.id_ex ,paex.ex_nom FROM utilisateur ut LEFT JOIN (SELECT c_nom ,ex_nom ,co.id_cour ,id_ex ,et.fk_util FROM etude et JOIN cour co ON et.fk_cour = co.id_cour LEFT JOIN examen ex2 ON co.id_cour = ex2.fk_cour) coex ON coex.fk_util = ut.id_util LEFT JOIN (SELECT * FROM passer pa JOIN examen ex ON pa.fk_ex = ex.id_ex) paex ON paex.fk_util = ut.id_util AND paex.id_ex = coex.id_ex ORDER BY id_util; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload