From: Richard Reina [mailto:[EMAIL PROTECTED]

> I have two tables:
> 
> EVENT
> ID        name                             date               
>    sponsor_ID
> 23       Sady Hawkins              2004-11-04       235
> 89       Founders Day               2004-12-21       NULL
> 87       Winter Gala                  2004-01-23       NULL
> 
> SPONSOR
> ID      name              
> 235   George Suter
> 34      William Riggs
> 896    Lidia   Bronson
> 
> I am having trouble writing a query that joins both tables 
> but will pull 
> up an event even if it  DOES NOT have a sponsor. 
> 
> SELECT FROM e.name, e.date, s.name
> FROM event e, sponsor s
> WHERE e.sponsor_ID = s.ID
> 
> This query works only for those events that have a sposor.
> 
> Any help would be greatly appreciated.


You need to use a LEF JOIN instead of the default:

SELECT e.name, e.date, s.name 
FROM event e 
LEFT JOIN sponsor s 
ON e.sponsor_ID = s.ID

HTH!


-- 
Mike Johnson
Web Developer
Smarter Living, Inc.
phone (617) 886-5539

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to