🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #10957

Re: JOINING 3 TABLES

#10957
From: amita
Date: Tue, 31 Dec 2002 06:30
74 lines
3241 bytes
Try

select
    oc.*,
    des.NOMBRE,
    ar.CODIGO, ar.CODIGO_BARON,  ar.CODIGO_S_PROV
 from
    ORDEN_COMPRA_1 oc inner join DESCRIPCIONES des on (oc.ID_ARTICULO =
des.ID) inner join
    ARTICULO ar on (oc.ID_ARTICULO = ar.ID)
 where
  oc.NUMERO = :NUMERO  and
  des.ID_TIPO_DES = ( Select ID_TIPO_DES  from MainPurChaseOrderTable
 where MainPurChaseOrderTable.NUMERO =:NUMERO)

The subquery here  gets the ID_TIPO_DES (Spanish/ English) from the main
Purchase order given the
Purchase Order No

--
Amita
Agnisoft, India

"Sergio Gonzalez" <shg@sion.com> wrote in message
news:3e111bfd$1@newsgroups.borland.com...
> Thanks for replying Bill!
> I'll try to put it clear:
>
> the SELECT statement I've posted is supposed to be the SelectSQL of my
> Purchase_Orders_Items table. It is the detail table of other that has the
> fields NUMERO and ID_TIPO_DES. I insist in this matter, because I know
that
> the master table will pass the parameter for NUMERO (that's the PK) but:
>
> it will pass the parameter for ID_TIPO_DES ?? if doesn't here I have my
> first problem. This field represent the "kind of description" of the items
> in all the lines of the purchase order (I.e.: all the descriptions may be
in
> English or Spanish) The user types it when he creates a new purchase
order.
>
> I need to show all the selected fields in a dbGrid. But I only see the
> fields that belongs to the main table (ORDEN_COMPRA_1) the others remain
> blank. Actually when I pull down the listbox in order to choose the field
> name in the FieldName property of the column property of the dbGrid I see
> only the fields of ORDEN_COMPRA_1.
>
> I'm not using the JOIN clause because I don't know how to use it with more
> than 2 tables.
>
> Here I post the select again:
>
> select
>    oc.*,
>    des.NOMBRE,
>    ar.CODIGO, ar.CODIGO_BARON,  ar.CODIGO_S_PROV
> from
>    ORDEN_COMPRA_1 oc,
>    DESCRIPCIONES des,
>    ARTICULO ar
> where
>    oc.NUMERO = :NUMERO  and
>    oc.ID_ARTICULO = des.ID and
>    oc.ID_ARTICULO = ar.ID   and
>    des.ID_TIPO_DES = :ID_TIPO_DES
>
>
> Thanks again!
>
>
> Sergio
>
>
>
Technical Details
Message-ID: <3e113850@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!cyclone.bc.net!news-hog.berkeley.edu!ucberkeley!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3e10b17c@newsgroups.borland.com> <27f11v8svcl7nf4u3v6ja8fvrmshonp1tn@4ax.com> <3e111bfd$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 114a0e,287ab2d1cf2e4217
X-Google-Attributes: gid114a0e,public
X-Google-ArrivalTime: 2002-12-30 22:34:01 PST
From: "amita" <amita@agnisoft.com>
Newsgroups: borland.public.interbase.sql
References: <3e10b17c@newsgroups.borland.com> <27f11v8svcl7nf4u3v6ja8fvrmshonp1tn@4ax.com> <3e111bfd$1@newsgroups.borland.com>
Subject: Re: JOINING 3 TABLES
Date: Tue, 31 Dec 2002 12:00:53 +0530
Lines: 76
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 203.195.196.78
Message-ID: <3e113850@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1041315920 203.195.196.78 (30 Dec 2002 22:25:20 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!cyclone.bc.net!news-hog.berkeley.edu!ucberkeley!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail