i have a search string $searchStr = 'anti' and have table mytable
i want to fetch data according to Keywords like if i search "anti" it fetch results with id 1,2,3
尝试这个
select * from table WHERE Keywords like '%anti%';
If you use 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.