Page 1 of 1

finding and deleting string match in mysql

Posted: Fri Jul 08, 2011 12:40 am
by eccen
I am wondering if there is a way to find and delete from a mysql table that begins with a certain string.

$string = 'abc'

and in mysql table there is a column 'name'

name
=====
abc
abcdef
abc123
aewfabc
aabc

When I run the code, it should delete three rows 'abc', 'abcdef', and 'abcd123'.
Is there a way to do this? I am not sure if there is a mysql query option to do this.. or should I implement strpos() some how?

Re: finding and deleting string match in mysql

Posted: Fri Jul 08, 2011 12:55 am
by eccen
I think I found answer myself using "LIKE '%John'" but if there is a better way please let me know!