× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



You are welcome Glenn,
I was not sure that "Not Exists" would work. I also think that the
subselect could also have selected "1 from GoodFile b" instead of naming
all of the fields. The important part of the subselect is the WHERE
statement that matches records from GoodFile with BadFile. So the statement
could have looked like;

delete
from BadFile a
where not exists
(select 1
from GoodFile b
where a.company = b.company
and a.debtor = b.debtor
and a.cc = b.cc
and a.yy = b.yy
and a.mm = b.mm
and a.slsman = b.slsman )

Jim


On Tue, Jun 17, 2008 at 8:06 PM, Glenn Gundermann <ggundermann@xxxxxx>
wrote:

Jim,

Thank you very much for taking the time to reply and sharing your
knowledge!
This was very valuable and I can't thank you enough.

Take care,

Glenn Gundermann :-)
ggundermann@xxxxxx
Cell: 416-317-3144

----- Original Message -----
From: "Jim Essinger" <dilbernator@xxxxxxxxx>
To: "Midrange Systems Technical Discussion" <midrange-l@xxxxxxxxxxxx>
Sent: Tuesday, June 17, 2008 12:57 AM
Subject: Re: SQL: How to delete records based on another file


Glen,
I would try something like this. I don't have a system available to test
on, so test well.

delete
from BadFile a
where not exists
(select b.company, b.debtor, b.cc, b,yy, b,mm, b,slsman
from GoodFile b
where a.company = b.company
and a.debtor = b.debtor
and a.cc = b.cc
and a.yy = b.yy
and a.mm = b.mm
and a.slsman = b.slsman )

HTH

Jim

On Mon, Jun 16, 2008 at 9:03 PM, Glenn Gundermann <ggundermann@xxxxxx>
wrote:

Hi folks,

I have a file with some extra records I would like to delete and I am
hoping someone can help me. Here is the scenario:

Let's say I have a file called GoodFile, and it has data like so:
company, debtor, cc, yy, mm, slsman, plus other fields
61,1234567, 20, 08, 01, 1234
61,1234567, 20, 08, 02, 5678
61,1234567, 20, 08, 03, 6789

Let's say I have another file called BadFile, and it has data like so:
company, debtor, cc, yy, mm, slsman, plus other fields
61,1234567, 20, 08, 01, 1234
61,1234567, 20, 08, 01, 4321
61,1234567, 20, 08, 01, 1111
61,1234567, 20, 08, 02, 5678
61,1234567, 20, 08, 02, 8765
61,1234567, 20, 08, 02, 2222
61,1234567, 20, 08, 03, 6789

I would like to remove the records from BadFile that don't have a match
(based on 6 fields shown) in GoodFile.

Thanks.

Glenn Gundermann
ggundermann@xxxxxx
New Cell #: 416-317-3144

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.