MySQL query String contains MySQL query String contains php php

MySQL query String contains


Quite simple actually:

mysql_query("SELECT *FROM `table`WHERE `column` LIKE '%{$needle}%'");

The % is a wildcard for any characters set (none, one or many). Do note that this can get slow on very large datasets so if your database grows you'll need to use fulltext indices.


Use:

SELECT *  FROM `table` WHERE INSTR(`column`, '{$needle}') > 0

Reference: