Jump to content

How to delete identical data from table A found in Table B with Mysql ?


benoit1980

Recommended Posts

Hello,

 

I would like to know if someone could tell me by giving me the php command on how to remove user accounts from Table A which are found in Table B?

 

My table B are the unsubscribed users from Mailchimp while table a are the one subscribed from my website. Unfortunately, it is impossible to have the row deleted from Mailchimp in mysql so the only way to do this is to delete the users between the 2 tables...

 

Any idea please?

 

Thank you,

 

Ben

You mean the MySQL query, not the "PHP command", correct? You didn't provide any details of the fields in the two tables or what logic should be used to determine that a record from Table A is the same as a record from Table B. Also, based upon your explanation you are wanting to delete the Subscribed user records and leave the un-susbscribed user records - that seems backwards, But, generically speaking, let's say the email address is used to determine that the user records are the same

 

 

DELETE FROM table_a
WHERE user_email IN (
    SELECT user_email
    FROM table_b
)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.