At 4:42 PM -0500 9/4/01, Islam, Sharif wrote:
>I have this two table.
>
>table1:
>
>ID  Name    Phone             someother fileds....
>1   Bob        1234
>2   Joe     5678
>3   Mary    5678
>4   John   6789
>
>table2:
>
>ID Name    Email
>1  Bob     [EMAIL PROTECTED]
>2  Joe     [EMAIL PROTECTED]
>3  John    john@
>----------------
>
>the query :
>select t1.Name, t1.Phone , t2.Email from t1,t2 where t1.name=t2.name works
>fine.
>
>But I want to display all the names. Table2 doesn't have all the names, so
>for example mary is missing , because she doesn't have email address. I want
>to display all the info about everyone, regardless if they have email
>address or not. Is that make sense? Any hint.

Use a LEFT JOIN to force the output to contain a row for every record
in t1, whether or not t2 contains a match:

select t1.Name, t1.Phone , t2.Email from t1 LEFT JOIN t2 ON t1.name=t2.name

The value of t2.Email for t1 rows with no match in t2 will be NULL.

>
>thanks


-- 
Paul DuBois, [EMAIL PROTECTED]

---------------------------------------------------------------------
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