finding and deleting string match in mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
eccen
Forum Newbie
Posts: 6
Joined: Fri Mar 28, 2008 12:41 am

finding and deleting string match in mysql

Post 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?
eccen
Forum Newbie
Posts: 6
Joined: Fri Mar 28, 2008 12:41 am

Re: finding and deleting string match in mysql

Post by eccen »

I think I found answer myself using "LIKE '%John'" but if there is a better way please let me know!
Post Reply