SQL query to delete records containing part of a string?

I have a MySQL table where I want to delete all records containing part of a row -

for example, in the "photo_name" field, many entries may have these lines:

testb-image-0.jpg
testc-image-0.jpg
testd-image-0.jpg
etc ...

I want to delete all entries that have the term "image-0" as part of the line in this field "photo_names" -

How to delete records based on part of a string?

+3
source share
1 answer
where photo_name like '%image-0.jpg'

Note that %indicates zero or more characters.
You can also use _, which denotes exactly 1 character.

+9
source

All Articles