MySQL query String contains

Posted by arik-so on Stack Overflow See other posts from Stack Overflow or by arik-so
Published on 2010-04-08T17:51:25Z Indexed on 2010/04/08 17:53 UTC
Read the original article Hit count: 273

Filed under:
|
|
|
|

Hello.

This may sound easy, but I've been trying - in vain, apparently - to figure out how I can make a query with MySQL that checks if the value (string $haystack ;) ) in a certain column contains certain data ( $needle ;) ), like this:

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

In PHP, the function is called substr($haystack, $needle), so maybe:

WHERE substr(`column`, '{$needle}')=1

Thanks in advance!

© Stack Overflow or respective owner

Related posts about mysql

Related posts about string