Jump to content

Outer join with multiple tables - not working


goodmood_ch

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

Link to comment
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.