Search code examples
sqlsql-delete

How to DELETE in SQL with multiple conditions


I have a table with one column called name_of, I have a lot of duplicates in this table, I have some python code, that takes all the duplicates and then concat them into the SQL query. But I have tried for some time with no luck.

TableName = users_from_group

Column = name_of

i have tried the following sql query:

DELETE FROM users_from_group
WHERE name_of = ('AskeMeyer'), ('testuser'), ('AskeMeyer'), ('testuser'), ('testuser'), ('AskeMeyer')

and I don't understand why this is not working, as this is the format of data for querying adding into the table?


Solution

  • the best way to do this is:

    DELETE FROM users_from_group
    WHERE name_of IN ('AskeMeyer', 'testuser', 'AskeMeyer', 'testuser', 'testuser', 'AskeMeyer')
    

    If this is useful for you, I would appreciate to mark as resolved. Cheers