delete multiple rows?

  • Ive got about 600 accounts that I need to delete from the database but every time i try to delete multiple accounts at a time i get an error message or it doesnt affect any rows.

    ive tried

    DELETE FROM Member

    WHERE Email = 'email@email.com, email2@email.com'

    which doesnt do anything

    DELETE FROM Member

    WHERE Email = 'email@email.com' AND 'email2@email.com'

    etc

    any tutorials or examples that show me how to delete multiple rows in a single table?

    id rather write out a decent sized query then have to go through and write a query for each..

  • try

    DELETE FROM Member

    WHERE Email in ( 'email@email.com' , 'email2@email.com')

  • awesome that works, thanks.

  • If you have the list of accounts available in a table, you could alter your syntax to:

    DELETE FROM Member

    WHERE Email IN (SELECT Account FROM AccountTable);

    If you have this list in Excel - you can import it to a table so you can use the above instead of typing in all 600 manually.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • Thanks, next time ill be sure to do the excel import table way so i dont have to do a huge query.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply