I have a MySQL table where I want to delete all the entries that contain a part of a string -
for example, in the field "photo_name", a lot of entries might have strings like these:
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 string in this "photo_names" field -
How do you delete entries based on a part of a string?
DELETE FROM mytable WHERE photo_name LIKE '%image-0.jpg'
Note that %
stands for zero or more characters.
You can also use _
which stands for exactly 1 character.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With