Creating delete queries

K

Kristine M

My company provides an email marketing campaign that each time we run the
program, it increments several (but not all) fields in my database with a 1,
2, 3 or more. I want to delete all records that are incremented after each
campaign is run. I have been deleting the records manually,but most tables
have 50,000+records. Is there a way to create a delete query in this case?
 
D

Duncan Bachen

Kristine said:
My company provides an email marketing campaign that each time we run the
program, it increments several (but not all) fields in my database with a 1,
2, 3 or more. I want to delete all records that are incremented after each
campaign is run. I have been deleting the records manually,but most tables
have 50,000+records. Is there a way to create a delete query in this case?

Its certainly possible, assuming that you know what criteria you are
looking for. What do you mean by 'incrementing the fields'? Do you mean
it used to have a value of 1, and now it has a value of 2?

In order for you delete query to work, you'd have to know your cutoff
criteria. You could make your criteria be > 1, assuming that the
original value was 1.

Maybe you could give an example?
 
K

Kristine M

Thanks for your quick response. The fields have an original value of 0.
Here is an example of my table before the campaign:

ID Email_Address Message_Sent Hard_Bounce Unsubscribe
Bad_Format
15150 (e-mail address removed) 0 0 0 0
15158 (e-mail address removed) 0 0 0 0
15163 dynamic2yahoo 0 0 0 0
15164 (e-mail address removed) 0 0 0 0

Here is what the table might look like after the campaign is run:
ID Email_Address Message_Sent Hard_Bounce Unsubscribe
Bad_Format
15150 (e-mail address removed) 1 0 1 0
15158 (e-mail address removed) 1 0 0 0 115163
dynamic2yahoo 0 2 0 2
15164 (e-mail address removed) 0 1 0 0

I need to be able to delete all records that have a 1 or more in the
Hard_Bounce, Unsubscribe, or Bad_Format fields.
 
V

Van T. Dinh

Try a Query (on a test copy of your database, of course) with SQL like:

DELETE *
FROM [YourTable]
WHERE ([Hard_Bounce] > 0)
OR ([Unsubscribe] > 0)
OR ([Bad_Format] > 0)
 
K

Kristine M

Thank you, that works very well
Kristine M

Van T. Dinh said:
Try a Query (on a test copy of your database, of course) with SQL like:

DELETE *
FROM [YourTable]
WHERE ([Hard_Bounce] > 0)
OR ([Unsubscribe] > 0)
OR ([Bad_Format] > 0)
--
HTH
Van T. Dinh
MVP (Access)



Kristine M said:
Thanks for your quick response. The fields have an original value of 0.
Here is an example of my table before the campaign:

ID Email_Address Message_Sent Hard_Bounce Unsubscribe
Bad_Format
15150 (e-mail address removed) 0 0 0 0
15158 (e-mail address removed) 0 0 0 0
15163 dynamic2yahoo 0 0 0 0
15164 (e-mail address removed) 0 0 0 0

Here is what the table might look like after the campaign is run:
ID Email_Address Message_Sent Hard_Bounce Unsubscribe
Bad_Format
15150 (e-mail address removed) 1 0 1 0
15158 (e-mail address removed) 1 0 0 0
115163
dynamic2yahoo 0 2 0 2
15164 (e-mail address removed) 0 1 0 0

I need to be able to delete all records that have a 1 or more in the
Hard_Bounce, Unsubscribe, or Bad_Format fields.
 

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

Top