By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,178 Members | 987 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,178 IT Pros & Developers. It's quick & easy.

Join question

P: n/a
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.

Travis

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 11 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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 ma*******@postgresql.org

Nov 11 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.