Jump to content

Archived

This topic is now archived and is closed to further replies.

goodmood_ch

Outer join with multiple tables - not working

Recommended Posts

Hello,

 

The most important tables in this query are \"ticket\" and \"employes\"

 

\"ticket\" as an idEmploye (to retrieve the coresponding employe), which can be null

 

I want to list the tickets for all idEmployees ( where null and not null)

Here is the query

 


$sql = "SELECT  T.idTicket, T.titreTicket , T.dateOuverture, E.nomEtatTicket, T.idEtatTicket, EM.userNameEmpl, T.ouvertPar ";

$sql .="FROM tickets T, etatsTickets E, employes EM ";

$sql .="WHERE  T.idEtatTicket IN (1,2,3) ";

$sql .="AND T.idProjet = $idProjet ";

$sql .="AND E.idEtatTicket = T.idEtatTicket ";

$sql .="AND T.idEmploye *= EM.idEmploye ";

<-- Dont know how to make this outer join with mysql

 

Thanks for your answers

Share this post


Link to post
Share on other sites

[php:1:f8e2758d66]<?php

$sql = \"SELECT T.idTicket, T.titreTicket , T.dateOuverture, E.nomEtatTicket, T.idEtatTicket, EM.userNameEmpl, T.ouvertPar

FROM (tickets T INNER JOIN etatsTickets E

ON E.idEtatTicket = T.idEtatTicket )

LEFT JOIN employes EM

ON T.idEmploye = EM.idEmploye

WHERE T.idEtatTicket IN (1,2,3)

AND T.idProjet = $idProjet \";

?>[/php:1:f8e2758d66]

 

 

 

hth

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.