Its seems like one of my users have been clicking on a send button twice to send an e-mail to the members.
The e-mail is stored in my db and what I can see there are duplicates of everyone, so I paused the loop where it’s being sent.
Now I would like to remove the duplicates but not sure how do this in a table.
Is there a simple way to remove the duplicates that have the same send_code and where sent=0
There are probably close to 1000 rows.
Next step I need to see how it’s possible that the user could click that start button twice.
DELETE * FROM TableName WHERE send_code=TheValueYouWantToDelete AND sent=0
Well, not exactly what I’m looking for. That one will delete even the ones that haven’t been sent. There are some duplicates left where I ONLY want to remove the duplicates.
The email has a unique code (m7g44pys) called send_code but I don’t want to delete all those that haven’t been sent, since there are a number of unsent that has to be sent as well.
So I want to list all unsent ones that have a unique e-mail for that send_code.
I tried this, but I don’t think it’s right:
SELECT DISTINCT email, sent, send_code, send_id FROM to_send_table WHERE send_code= 'm7g44pys' AND sent = '0';
Or if I can see in phpmyadmin just the ones that are double, then I can delete them there by selecting them all in the list.
But I just don’t know how to make the query. Is there a way to do something like this
SELECT * FROM to_send_table WHERE sent = '0'
and then add something that looks if there are more than one email, with a count or whatever…
Now I did this and I think it’s right?
WHERE send_code = 'm7g44pys'
AND sent = '0'
GROUP BY email
HAVING COUNT( * ) >1
ORDER BY `to_send_table`.`email` ASC