Jump to content


Photo

Outer join with multiple tables - not working


  • Please log in to reply
2 replies to this topic

#1 goodmood_ch

goodmood_ch
  • New Members
  • Pip
  • Newbie
  • 2 posts
  • LocationSwitzerland

Posted 14 November 2003 - 10:10 AM

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

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 14 November 2003 - 02:23 PM

[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
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 goodmood_ch

goodmood_ch
  • New Members
  • Pip
  • Newbie
  • 2 posts
  • LocationSwitzerland

Posted 14 November 2003 - 02:28 PM

works fine,
thanks a lot !




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users