RE: [PHP] SQL : left join from multiple tables
| From: | Faisal Abdullah | Date: | Wed, 25 Sep 2002 01:58:19 +0000 |
| Subject: | RE: [PHP] SQL : left join from multiple tables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-117488@lists.php.net to get a copy of this message | ||
Thanks for the help.
I got it working.
I used SQL92, instead of Oracle's sql standard.
I just hate to recode when migrating to mysql or postgresql.
Sincerely,
Faisal
-----Original Message-----
From: Jay Blanchard [mailto:jay.blanchard@niicommunications.com]
Sent: Tuesday, September 24, 2002 7:33 PM
To: 'Faisal Abdullah'; php-general@lists.php.net
Subject: RE: [PHP] SQL : left join from multiple tables
[snip]
"select a.name, b.department, c.position
from emp a
left join dept b
on a.staffno = b.staffno
left join position c
on a.staffno = c.staffno
where staffno = $staffno";
I know the statement above is totally wrong. I'm just hoping u guys can
understand what i'm trying to achieve from it.
[/snip]
All you have to change to make this right is change the ON statement after
'left join position c' to 'on b.staffno = c.staffno'. Remember that you are
moving from left to right in the join, so your ON must also move from left
to right.
HTH!
Jay
______________________________________