🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Help with a "not in" query

#233
From: Hugo
Date: Sun, 15 Jun 2008 21:48
38 lines
1686 bytes
Hello

I am having trouble wit a query, I want to select all the records from 
table_1 that not exist in table_2

Some fields on TABLE_1 and TABLE_2 have to be the same, like 
ID_ARTICULO, ID_VENTA and OPCION

TABLE_1 has 35000+ records

TABLE_2 has 28500+ records

I have tried these two methods, but IBconsole stop responding on both 
methods.



select * FROM TABLE_1
	WHERE ID_VENTA = 20081398
	AND OPCION = 1
	AND ID_ARTICULO NOT IN (
		SELECT ID_ARTICULO FROM TABLE_2
		WHERE ID_VENTA = 20081398
		AND OPCION = 1);


SELECT * FROM TABLE_1 T1
	WHERE T1.ID_VENTA = 20081398
	AND T1.OPCION = 1
	AND NOT EXISTS (
		SELECT * FROM TABLE_2 T2
		WHERE T2.ID_VENTA = 20081398
		AND T2.OPCION = 1
		AND T2.ID_ARTICULO = T1.ID_ARTICULO);

Any help will be appreciated, regards.

Hugo.
Technical Details
Message-ID: <48558e17$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!npeer03.iad!npeer01.iad!news.highwinds-media.com!newsfeed2.telusplanet.net!newsfeed.telus.net!feeder.erje.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,82d9b914a86c4cad
X-Google-Attributes: gid114a0e,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Sun, 15 Jun 2008 23:48:05 +0200
From: Hugo <hugo@hugohiram.com>
User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
MIME-Version: 1.0
Newsgroups: borland.public.interbase.sql
Subject: Help with a "not in" query
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 77.224.139.205
Message-ID: <48558e17$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1213566487 77.224.139.205 (15 Jun 2008 14:48:07 -0700)
Lines: 38
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!npeer03.iad!npeer01.iad!news.highwinds-media.com!newsfeed2.telusplanet.net!newsfeed.telus.net!feeder.erje.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail