From: | "Williams, Travis L, NEO" <tlw(at)att(dot)com> |
---|---|
To: | "Thomas A(dot) Lowery" <tlowery(at)stlowery(dot)net> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Join question |
Date: | 2003-08-29 02:03:25 |
Message-ID: | AB815D267EC31A4693CC24D234F8291605A0C671@ACCLUST02EVS1.ugd.att.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Yeah.. so that's why I didn't know if I could do it all in the same
statement.
Travis
-----Original Message-----
From: Thomas A. Lowery [mailto:tlowery(at)stlowery(dot)net]
Sent: Thursday, August 28, 2003 8:54 PM
To: Williams, Travis L, NEO
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] Join question
On Thu, Aug 28, 2003 at 09:46:34PM -0400, Williams, Travis L, NEO wrote:
> That would probably work great.. except I screwed my question up..
Let
> me try again and this time think before I write
>
> I have a table1 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 "select d from table2 where d like '%b%'" There is
> nothing to join between table1 & table2 (unless you can join on likes
;)
> ).
So the second select uses the value of table1 column b in the like
condition?
> -----Original Message-----
> From: Thomas A. Lowery [mailto:tlowery(at)stlowery(dot)net]
> Sent: Thursday, August 28, 2003 8:06 PM
> To: pgsql-general(at)postgresql(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn van Oosterhout | 2003-08-29 02:11:09 | Re: mysql's last_insert_id |
Previous Message | Thomas A. Lowery | 2003-08-29 01:54:15 | Re: Join question |