Re: Join question - Mailing list pgsql-general

From Williams, Travis L, NEO
Subject Re: Join question
Date
Msg-id AB815D267EC31A4693CC24D234F8291605A0C663@ACCLUST02EVS1.ugd.att.com
Whole thread Raw
In response to Join question  ("Williams, Travis L, NEO" <tlw@att.com>)
List pgsql-general
Sure.. if it works.. I'm just trying to not have to make multiple calls
to the DB..  I'll try it out..

Thanks,

Travis

-----Original Message-----
From: Thomas A. Lowery [mailto:tlowery@stlowery.net]
Sent: Thursday, August 28, 2003 8:06 PM
To: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Join question


Does using a union count as one query?

select a from tst_1 where b is null
union
select d from tst_2 t2 join tst_1 t1 on (t1.b = t2.c)
where t1.b is NOT null


On Thu, Aug 28, 2003 at 05:55:27PM -0400, Williams, Travis L, NEO wrote:
> Question,
>
> I have a table (1) with 2 col (a & b) where b can sometimes be null. I
> need a query that if B is null I get back the contents of A.. but if B
> is not null I do a join on it and table (2) col c to get the contents
> of table (2) col d.. I can do this in multiple queries.. but was
> wondering if I could do it in 1.


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

pgsql-general by date:

Previous
From: "Clay Luther"
Date:
Subject: Re: left outer join terrible slow compared to inner join
Next
From: Alex
Date:
Subject: Re: Arrays and Indices / Foreign Keys