Tuesday, 27 June 2017

MySQL query String contains

Quite simple actually:
mysql_query("
SELECT *
FROM `table`
WHERE `column` LIKE '%{$needle}%'
");
The % is a wildcard for any character. Do note that this can get slow on very large datasets so if your database grows you'll need to use fulltext indices.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.

Blog Archive