UNION help

Started by Robert Jamesalmost 19 years ago4 messagesgeneral
Jump to latest
#1Robert James
srobertjames@gmail.com

Is there anyway to tell if the records in a union came from the 1st query or
the second?
Can I modify the individual queries to let me know this?

#2Ben
bench@silentmedia.com
In reply to: Robert James (#1)
Re: UNION help

You could modify the queries and then do a union all... but then you may
see the same result from each part of the union. Which may or may not be a
problem for you.

On Thu, 17 May 2007, Robert James wrote:

Show quoted text

Is there anyway to tell if the records in a union came from the 1st query or
the second?
Can I modify the individual queries to let me know this?

#3Scott Marlowe
smarlowe@g2switchworks.com
In reply to: Robert James (#1)
Re: UNION help

Robert James wrote:

Is there anyway to tell if the records in a union came from the 1st
query or the second?
Can I modify the individual queries to let me know this?

You can do something like:

select 'set1' as identifier, field1, field2 from table1
union
select 'set2', field1, field2 from table2

#4Dann Corbit
DCorbit@connx.com
In reply to: Robert James (#1)
Re: UNION help

SELECT '1st Query' as whichone, col1, col2, col3 from table1

UNION

SELECT '2ND Query' as whichone, col1, col2, col3 from table2

________________________________

From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of Robert James
Sent: Thursday, May 17, 2007 12:11 PM
To: pgsql-general@postgresql.org
Subject: [GENERAL] UNION help

Is there anyway to tell if the records in a union came from the 1st
query or the second?
Can I modify the individual queries to let me know this?