Re: how to do this query?

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: how to do this query?
Дата
Msg-id 200305201736.47227.dev@archonet.com
обсуждение исходный текст
Ответ на how to do this query?  (ww zz <ts_999@yahoo.com>)
Список pgsql-sql
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


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Jan Bodey"
Дата:
Сообщение: Date comparison question
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: how to do this query?