Search code examples
mysqlsql-deletesubstr

MYSQL DELETE rows in query with substr


I would like to remove rows table1.name from table where table1.name starts with 'product-'

mysql_request("DELETE FROM table1 WHERE substr(name, 0, 8) = 'product-'");

It's very ridiculous but this query doesn't work at all. Any ideas how to make it?


Solution

  • the key is start with 'product'. Try:

    DELETE FROM table1 WHERE name like 'product-%'