gython
gython

Reputation: 875

How can I delete multiple rows in a database table where specific conditions are not met?

I am trying to delete specific rows in a database table where specific conditions are not met. This is the SQL command:

DELETE FROM table WHERE URL NOT LIKE "%/meldung/%" or NOT LIKE "%/artikel/%"

I want to delete every row in the URL column which does not contain /meldung/ or /artikel/, but this command just keeps the rows which contain /artikel/ AND /meldung/ in the URL.

Somebody can help?

Upvotes: 0

Views: 72

Answers (2)

Zaynul Abadin Tuhin
Zaynul Abadin Tuhin

Reputation: 32003

try like below you missed column name after or

DELETE FROM table WHERE URL NOT LIKE "%/meldung/%" and 
URL NOT LIKE "%/artikel/%"

Upvotes: 0

Kemal AL GAZZAH
Kemal AL GAZZAH

Reputation: 1037

You use either

DELETE FROM table WHERE not(URL LIKE "%/meldung/%" or URL LIKE "%/artikel/%")

or

DELETE FROM table WHERE (URL not LIKE "%/meldung/%" and URL not LIKE "%/artikel/%")

Upvotes: 1

Related Questions