[英]how to search from comma separated column value in mysql
i have a search string $searchStr = 'anti' and have table mytable 我有一个搜索字符串$ searchStr ='anti'并有表mytable
i want to fetch data according to Keywords like if i search "anti" it fetch results with id 1,2,3 我想根据关键字获取数据,例如,如果我搜索“ anti”,它将获取ID为1,2,3的结果
尝试这个
select * from table WHERE Keywords like '%anti%';
If you use mysqli
: 如果您使用
mysqli
:
$stmt = $mysqli->prepare('SELECT * FROM mytable WHERE find_in_set(?, myField) <> 0');
$stmt->bind_param('s', $searchStr);
$stmt->execute();
Use the FIND_IN_SET function. 使用FIND_IN_SET函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.