On Tuesday 20 May 2003 5:00 pm, ww zz wrote:
> New to sql and may be a simple question for you:
>
> I have four tables
>
> sample: sid, sname
> make: sid, mdate
> measure: sid, mdate, rid
> result: rid, resultdata
>
> for a gaven sample it always has a sid and sname, but
> it may or may not have any entries in the other
> tables, the sample could be measured more than once
> and each measure give a result row.
You'll want to use a LEFT JOIN, something like:
SELECT s.sid, s.sname, m.mdate, m.rid, r.resultdata
FROM sample s LEFT JOIN measure m ON s.sid=m.sid LEFT JOIN result ON
m.rid=r.rid
You'll get nulls where there are no matches.
-- Richard Huxton