delete multiple DB entries?

R

Rudi Ahlers

A different question though. Is it possible to delete duplicate entries,
where the email address is the same, and only keep one?
i.e..

I got say 4 DB entries, all with the same email address, and I want to
delete 3. How do I do this?

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
 
M

Maarten

RS.OPEN "SELECT * FROM MyTable WHERE myMail = '(e-mail address removed)' ORDER BY
myMail"

RS.MoveNext (skip the first)

DO WHILE NOT RS.EOF
RS.Delete
RS.MoveNext
LOOP
 
B

Bob Barrows

Rudi said:
A different question though. Is it possible to delete duplicate
entries, where the email address is the same, and only keep one?
i.e..

I got say 4 DB entries, all with the same email address, and I want to
delete 3. How do I do this?

What is the database, please?
 
B

Bob Barrows

Rudi said:
A different question though. Is it possible to delete duplicate
entries, where the email address is the same, and only keep one?
i.e..

I got say 4 DB entries, all with the same email address, and I want to
delete 3. How do I do this?


What database please? Type and version.

Oh, and a little more information about the table structure would be
helpful. How do you want to decide which record to keep, and which ones to
discard?

Bob Barrows
 
R

Rudi Ahlers

Hi Bob

I thought about it, and here it is.

I have an excel file, with an odd 60.000 records. Then, I have a MySQL DB
with 24000 records. Now, those 24000 records also appear in the .xls file.
Thus, I only want to upload the "new" records. I have an MSSQL 2000 DB as
well, and though I'd use that to do the database sorting, but then it would
need to be exported again.

Unless there is a way of importing all the stuff. When it comes to a record
that already exists, to simply skip it, and go on with the next one?

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
Rudi said:
A different question though. Is it possible to delete duplicate
entries, where the email address is the same, and only keep one?
i.e..

I got say 4 DB entries, all with the same email address, and I want to
delete 3. How do I do this?


What database please? Type and version.

Oh, and a little more information about the table structure would be
helpful. How do you want to decide which record to keep, and which ones to
discard?

Bob Barrows
 
B

Bob Barrows

I know next-to-nothing about MySQL, but:
1. Since MySQL is the destination i would not involve MS SQL.
2. If possible, you should flag the records in excel that have already been
downloaded. Perhaps, create a new worksheet to contain only new email
addresses and import from that worksheet.
3. You should import the data into an intermediate table and then use the
following SQL statement to insert only the records that don't already exist
into the actual destination table (this example will be very generic since
you did not provide the details about your table structure):
Insert into emailtable(<columnlist>)
Select <columnlist>
FROM imported_data i
WHERE NOT EXISTS
(Select * FROM emailtable
WHERE email_address = i.email_address)

This sql statement will work in MS SQL. I do not know it MySQL supports this
syntax. You should find a MySQL forum or newsgroup and ask there if you
can't get it working.

Bob Barrows
 
R

Rudi Ahlers

ok, thanx. I see what you say, and that SQL statement is what I was looking
for.

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

Greater love has no one than this, that he lay down his life for his friends
(John 15:13).
I know next-to-nothing about MySQL, but:
1. Since MySQL is the destination i would not involve MS SQL.
2. If possible, you should flag the records in excel that have already been
downloaded. Perhaps, create a new worksheet to contain only new email
addresses and import from that worksheet.
3. You should import the data into an intermediate table and then use the
following SQL statement to insert only the records that don't already exist
into the actual destination table (this example will be very generic since
you did not provide the details about your table structure):
Insert into emailtable(<columnlist>)
Select <columnlist>
FROM imported_data i
WHERE NOT EXISTS
(Select * FROM emailtable
WHERE email_address = i.email_address)

This sql statement will work in MS SQL. I do not know it MySQL supports this
syntax. You should find a MySQL forum or newsgroup and ask there if you
can't get it working.

Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top