Received: from bjke.com (firewall-user@ganymede.bjke.com [144.210.8.38]) by hub.org (8.9.2/8.9.1) with ESMTP id OAA66418 for ; Wed, 3 Feb 1999 14:07:26 -0500 (EST) (envelope-from djackson@cpsgroup.com) Received: by bjke.com; id NAA25098; Wed, 3 Feb 1999 13:07:21 -0600 (CST) Received: from cpsmail.cpsgroup.com(144.210.12.11) by gauntlet.bjke.com via smap (4.1) id xmab24493; Wed, 3 Feb 99 13:06:48 -0600 Received: by cpsmail with Internet Mail Service (5.0.1458.49) id ; Wed, 3 Feb 1999 13:09:08 -0600 Message-ID: From: "Jackson, DeJuan" To: Andy , djackson@cpsgroup.com Cc: PGSQL SQL Subject: RE: Two table select (fwd) Date: Wed, 3 Feb 1999 13:09:06 -0600 X-Priority: 3 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.0.1458.49) Content-Type: text/plain You could use unions, but I must ask why do you have all those rbldg# columns in your table? What's the basic thought behind your database layout? -DEJ > -----Original Message----- > From: Andy [mailto:alewis@mpsi.net] > Sent: Wednesday, February 03, 1999 1:00 PM > To: djackson@cpsgroup.com > Subject: Two table select (fwd) > > > The apts table is at the bottom. > > I guess what I am trying to do is to pick each rbldg[x] from > the referral query > and then take that and query the apts table for the bldgname. > > rbldg[x] is the apt building number and bldgname is the building name. > > Thanks > > Andy > > > > I have two queries that I'd like to make as one. Here are the queries: > > select * from referral where oid = $some_oid > > select bldgname from apts where bldgnum = 'rbldg1' > > > I am trying to get the bldgname from the apts table and want > to get all of the > bldgname's including rbldg2, rbldg3, rbldg4. Trying to do it > in one select > statment, is this possible? > > > > table = referral > +----------------------------------+-------------------------- > --------+-------+ > | rstate | varchar() > | 2 | > | rrif | varchar() > | 10 | > | rphone | varchar() > | 20 | > | rfirstname | varchar() > | 20 | > | rlastname | varchar() > | 25 | > | rbldg1 | varchar() > | 10 | > | rbldgcomment1 | text > | var | > | rbldg2 | varchar() > | 10 | > | rbldgcomment2 | text > | var | > | rbldg3 | varchar() > | 10 | > | rbldgcomment3 | text > | var | > | rbldg4 | varchar() > | 10 | > .... > +----------------------------------+-------------------------- > --------+-------+ > > Table = apts > +----------------------------------+-------------------------- > --------+-------+ > | Field | Type > | Length| > +----------------------------------+-------------------------- > --------+-------+ > | bldgnum | varchar() > | 10 | > | bldgname | varchar() > | 35 | > ... > +----------------------------------+-------------------------- > --------+-------+ > > Thanks in advance > > Andy > > >