Creating delete queries

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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?
 
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.
 
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)
 
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.
 
Back
Top