X-Original-To: pgsql-sql@postgresql.org Received: from localhost (unknown [64.117.224.193]) by developer.postgresql.org (Postfix) with ESMTP id 8D2E1923517 for ; Tue, 20 May 2003 13:19:48 -0400 (EDT) Received: from developer.postgresql.org ([64.117.224.193]) by localhost (developer.postgresql.org [64.117.224.193:10024]) (amavisd-new) with ESMTP id 30524-10 for ; Tue, 20 May 2003 13:19:43 -0400 (EDT) Received: from web41805.mail.yahoo.com (web41805.mail.yahoo.com [66.218.93.139]) by developer.postgresql.org (Postfix) with SMTP id 10E489234CE for ; Tue, 20 May 2003 13:19:43 -0400 (EDT) Message-ID: <20030520171940.63419.qmail@web41805.mail.yahoo.com> Received: from [129.6.154.168] by web41805.mail.yahoo.com via HTTP; Tue, 20 May 2003 10:19:40 PDT Date: Tue, 20 May 2003 10:19:40 -0700 (PDT) From: ww zz Subject: Re: how to do this query? To: Stephan Szabo Cc: pgsql-sql@postgresql.org In-Reply-To: <20030520094321.T68048-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/394 X-Sequence-Number: 13559 another question is: if I do left outer join on a few big tables, will it be very slow? --- Stephan Szabo wrote: > On Tue, 20 May 2003, 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. > > question: > > how do I do a query that given a sid, it will > retrieve > > all the information available in the four tables, > if > > there are available. If, for example, all tables > have > > some entry for a gave sample it will retreve all > the > > information, if the "measure" and "result" are > empty > > for that sample it will give only the 'sample' and > > 'make' information.... > > Well, you're not going to get a limited column set, > but you can > get NULLs in the non-applicable table columns by > using outer joins. > > Maybe something like something like > select * from > sample left outer join make using (sid) > left outer join measure using (sid) > left outer join result using (rid) > where sid=; > > > ---------------------------(end of > broadcast)--------------------------- > TIP 2: you can get off all lists at once with the > unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) __________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com