pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
combining a single field in two tables into one column.
4+ messages / 3 participants
[nested] [flat]

* combining a single field in two tables into one column.
@ 1999-04-30 15:59 JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
  1999-04-30 16:15 ` Re: [SQL] combining a single field in two tables into one column. Chris Bitmead <chris.bitmead@bigfoot.com>
  0 siblings, 1 reply; 4+ messages in thread

From: JT Kirkpatrick @ 1999-04-30 15:59 UTC (permalink / raw)
  To: 'pgsql-sql@hub.org' <pgsql-sql@hub.org>

i come seeking wisdom. . .

i have two tables, one for subcontractors and another for vendors.  subs 
have a primary key of subnum int4, vendors a primary key of vnum int4.  i 
need to create a query that allows me to see a complete list of these 
numbers in a single column.  for instance, subnum (all begin with 9) has 
values 90001, 90002, 90003 (only three records for the example), and vnum 
(all begin with 2) has values 20001, 20002.  i'd like my query result to 
show:

90001
90002
90003
20001
20002

this does NOT work:  select a.subnum as z, b.vnum as z from subs a, vend b;
NOR does: select a.subnum, b.vnum from subs a, vend b;

by the way, the two tables DO NOT relate to each other (i.e., 90001 does 
not have anything to do with 20001). . .

TIA, jt



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [SQL] combining a single field in two tables into one column.
  1999-04-30 15:59 combining a single field in two tables into one column. JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
@ 1999-04-30 16:15 ` Chris Bitmead <chris.bitmead@bigfoot.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Chris Bitmead @ 1999-04-30 16:15 UTC (permalink / raw)
  To: 'pgsql-sql@hub.org' <pgsql-sql@hub.org>

You need something along the lines of 
SELECT subnum FROM subs UNION SELECT vnum FROM vend;


JT Kirkpatrick wrote:
> 
> i come seeking wisdom. . .
> 
> i have two tables, one for subcontractors and another for vendors.  subs
> have a primary key of subnum int4, vendors a primary key of vnum int4.  i
> need to create a query that allows me to see a complete list of these
> numbers in a single column.  for instance, subnum (all begin with 9) has
> values 90001, 90002, 90003 (only three records for the example), and vnum
> (all begin with 2) has values 20001, 20002.  i'd like my query result to
> show:
> 
> 90001
> 90002
> 90003
> 20001
> 20002
> 
> this does NOT work:  select a.subnum as z, b.vnum as z from subs a, vend b;
> NOR does: select a.subnum, b.vnum from subs a, vend b;
> 
> by the way, the two tables DO NOT relate to each other (i.e., 90001 does
> not have anything to do with 20001). . .
> 
> TIA, jt

-- 
Chris Bitmead
http://www.bigfoot.com/~chris.bitmead
mailto:chris.bitmead@bigfoot.com



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* RE: [SQL] combining a single field in two tables into one column.
@ 1999-04-30 16:02 Jackson, DeJuan <djackson@cpsgroup.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Jackson, DeJuan @ 1999-04-30 16:02 UTC (permalink / raw)
  To: JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>; 'pgsql-sql@hub.org' <pgsql-sql@hub.org>

try:
select subnum from subs
union all
select vnum from vend;
	-DEJ

> -----Original Message-----
> From:	JT Kirkpatrick [SMTP:jt-kirkpatrick@mpsllc.com]
> Sent:	Friday, April 30, 1999 10:59 AM
> To:	'pgsql-sql@hub.org'
> Subject:	[SQL] combining a single field in two tables into one
> column.
> 
> i come seeking wisdom. . .
> 
> i have two tables, one for subcontractors and another for vendors.  subs 
> have a primary key of subnum int4, vendors a primary key of vnum int4.  i 
> need to create a query that allows me to see a complete list of these 
> numbers in a single column.  for instance, subnum (all begin with 9) has 
> values 90001, 90002, 90003 (only three records for the example), and vnum 
> (all begin with 2) has values 20001, 20002.  i'd like my query result to 
> show:
> 
> 90001
> 90002
> 90003
> 20001
> 20002
> 
> this does NOT work:  select a.subnum as z, b.vnum as z from subs a, vend
> b;
> NOR does: select a.subnum, b.vnum from subs a, vend b;
> 
> by the way, the two tables DO NOT relate to each other (i.e., 90001 does 
> not have anything to do with 20001). . .
> 
> TIA, jt



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* RE: [SQL] combining a single field in two tables into one column.
@ 1999-04-30 16:09 JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
  0 siblings, 0 replies; 4+ messages in thread

From: JT Kirkpatrick @ 1999-04-30 16:09 UTC (permalink / raw)
  To: 'Jackson, DeJuan' <djackson@cpsgroup.com>; 'pgsql-sql@hub.org' <pgsql-sql@hub.org>

HAH, it worked!!!  i'll play with it -- i need it to now add a few more 
fields from each table, and then present them in order of (vnum, subnum) -- 
i also need to have it work from within access97 rather than from psql! 
 but i seem to always start at psql and then write the same query in 
access97. . .   thanks much!!!

jt

-----Original Message-----
From:	Jackson, DeJuan [SMTP:djackson@cpsgroup.com]
Sent:	Friday, April 30, 1999 12:03 PM
To:	JT Kirkpatrick; 'pgsql-sql@hub.org'
Subject:	RE: [SQL] combining a single field in two tables into one column.

try:
select subnum from subs
union all
select vnum from vend;
	-DEJ

> -----Original Message-----
> From:	JT Kirkpatrick [SMTP:jt-kirkpatrick@mpsllc.com]
> Sent:	Friday, April 30, 1999 10:59 AM
> To:	'pgsql-sql@hub.org'
> Subject:	[SQL] combining a single field in two tables into one
> column.
>
> i come seeking wisdom. . .
>
> i have two tables, one for subcontractors and another for vendors.  subs
> have a primary key of subnum int4, vendors a primary key of vnum int4.  i 
> need to create a query that allows me to see a complete list of these
> numbers in a single column.  for instance, subnum (all begin with 9) has
> values 90001, 90002, 90003 (only three records for the example), and vnum 
> (all begin with 2) has values 20001, 20002.  i'd like my query result to
> show:
>
> 90001
> 90002
> 90003
> 20001
> 20002
>
> this does NOT work:  select a.subnum as z, b.vnum as z from subs a, vend
> b;
> NOR does: select a.subnum, b.vnum from subs a, vend b;
>
> by the way, the two tables DO NOT relate to each other (i.e., 90001 does
> not have anything to do with 20001). . .
>
> TIA, jt



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~1999-04-30 16:15 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-04-30 15:59 combining a single field in two tables into one column. JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
1999-04-30 16:15 ` Chris Bitmead <chris.bitmead@bigfoot.com>
1999-04-30 16:02 RE: [SQL] combining a single field in two tables into one column. Jackson, DeJuan <djackson@cpsgroup.com>
1999-04-30 16:09 RE: [SQL] combining a single field in two tables into one column. JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox