You might want to use the full join syntax here to be clear on what is
happening.

select
  title as Title,
  COALESCE(o.name,'None') as Organization
from m
left join o on o.ID = m.organization

Also, notice COALESCE.  Much less messy.

Brian.

----- Original Message -----
From: "Quinten Steenhuis" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, August 20, 2002 2:18 PM
Subject: NULL values in a JOIN


|
| Sql, query
|
| > Hi,
| >
| > I have a field that I need to do a join on. Unfortunately, the column is
| > allowed to be null (and it should be). My plan is to return the literal
| > string 'None' if the column is null, and otherwise to return the joined
| > value. How can I do this, when the inner join that I want will exclude
the
| > rows where the column in question is null?
| >
| > eg:
| >
| > SELECT
| > ... as 'Motion Ref.', title as
| > Title,
| > IF(IFNULL(o.name,1<0),CONCAT('None'),o.name) as Organization,
| > ... as Date FROM m,o
| > WHERE (o.ID = m.organization)
| >
| > Quinten
|
|
| ---------------------------------------------------------------------
| Before posting, please check:
|    http://www.mysql.com/manual.php   (the manual)
|    http://lists.mysql.com/           (the list archive)
|
| To request this thread, e-mail <[EMAIL PROTECTED]>
| To unsubscribe, e-mail
<[EMAIL PROTECTED]>
| Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
|
|


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to