<?php
$searchText = "เขียนโปรแกรม php mysql";
$idArr = explode(" ", $searchText);
$condition = " title LIKE '%" . implode("%' OR title LIKE '%", $idArr) . "%' ";
$sql = "SELECT * FROM book WHERE " . $condition;
?>
ผลลัพธ์จะได้ด้งนี้
Code (PHP)
<?php
SELECT * FROM book WHERE title LIKE '%เขียนโปรแกรม%' OR title LIKE '%php%' OR title LIKE '%mysql%'
?>