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

Link to comment
Share on other sites

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
)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.