RE: [PHP-DB] Complex Left Join
| From: | Bastien Koert | Date: | Mon, 31 Oct 2005 20:31:24 +0000 |
| Subject: | RE: [PHP-DB] Complex Left Join | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-40576@lists.php.net to get a copy of this message | ||
try
SELECT
d.directorid,
d.fname,
d.mname,
d.lname,
d.title,
d.suffix,
d.active,
d.function,
m.id,
m.directorid,
m.committee,
m.position,
m.year
FROM
directors d left outer join members m
ON
d.directorid = m.directorid
WHERE
AND m.year = '2006'
ORDER BY
d.lname, d.mname, d.fname;
your original query was an inner join
Bastien
From: "Keith Spiller" <larentium@hosthive.com> To: "[PHP-DB]" <php-db@lists.php.net> Subject: [PHP-DB] Complex Left Join Date: Mon, 31 Oct 2005 13:29:18 -0700 Hi, Can anyone help me turn this into a left join? I want to get all of the records from the directors table whether matches exist in the members table or not. SELECT d.directorid, d.fname, d.mname, d.lname, d.title, d.suffix, d.active, d.function, m.id, m.directorid, m.committee, m.position, m.year FROM directors as d, members as m WHERE d.directorid = m.directorid AND m.year = '2006' ORDER BY d.lname, d.mname, d.fname; Thank you for your help... Keith