Search code examples
sqlwhere-clausesql-delete

SQL. DELETE Removal under several conditions (SQL. DELETE)


I have data base. I have to delete strings that meet several conditions: AND, OR Will delete people who were born from 2001-10-01 to 2010-10-01 and have names of the format XXXan or AnXXX, where X is an arbitrary symbol*

DELETE FROM people 
WHERE date> 2001-10-01 AND date < 2010-10-01 AND names LIKE ‘…an’ OR ‘An...’

But the second part of the request immediately applies AND to the first type of name, but I need the AND to select one of the two names.


Solution

  • You have to use brackets to group the conditions.

    DELETE FROM people 
    WHERE date> 2001-10-01 AND date < 2010-10-01 AND (names LIKE ‘…an’ OR ‘An...’)