MySQL query String contains

902    Asked by SadafSharma in SQL Server , Asked on Jul 1, 2021

 I've been trying 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 (string $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
Answered by Kaalappan shingh

You can use this query to solve contains mysql:

Query:

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


Your Answer

Interviews

Parent Categories