🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Query problem

#11250
From: Donato Verrastro
Date: Fri, 29 Nov 2002 11:09
23 lines
1869 bytes
I have a problem to write a query. Can you help me?
I have a two table:
CREATE TABLE1 (COD NUMBER(10,0),
                               YEAR NUMBER(10,0),
                               SUBCOD NUMBER(10,0),
                               ..,
                               PRIMARY KEY(COD,YEAR,SUBCOD));
and table2
CREATE TABLE2 (COD NUMBER(10,0),
                                YEAR NUMBER(10,0),
                                SUBCOD NUMBER(10,0),
                                ..,
                                PRIMARY KEY(COD,YEAR,SUBCOD));
I want to insert in TABLE1 all record of TABLE2 that are not present in
TABLE1.
How can I do this query?
I have write the following query but i think that it isn't correct.
INSERT INTO TABLE1
  SELECT .... FROM TABLE2
  WHERE COD||'-'||YEAR||'-'||SUBCOD NOT IN (SELECT
COD||'-'||YEAR||'-'||SUBCOD FROM TABLE2);
Thank you in advance
Donato Verrastro
Technical Details
Message-ID: <3de74a9e@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-04!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!opentransit.net!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 114a0e,793e98fa5f55bc1b,start
X-Google-Attributes: gid114a0e,public
X-Google-ArrivalTime: 2002-11-29 03:09:14 PST
From: "Donato Verrastro" <donato.verrastro@libero.it>
Newsgroups: borland.public.interbase.sql
Subject: Query problem
Date: Fri, 29 Nov 2002 12:09:23 +0100
Lines: 27
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: 217.59.166.66
Message-ID: <3de74a9e@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1038568094 217.59.166.66 (29 Nov 2002 03:08:14 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-04!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!opentransit.net!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail