如何搜索多列中的詞:title
,content
。例如:在多列中查找搜索詞
$searchTerm = 'android';
SELECT * FROM posts WHERE `title` OR `content` contains $SearchTerm
如何搜索多列中的詞:title
,content
。例如:在多列中查找搜索詞
$searchTerm = 'android';
SELECT * FROM posts WHERE `title` OR `content` contains $SearchTerm
SELECT *
FROM posts
WHERE
`title` LIKE '%android%'
OR `content` LIKE '%android%'
$sql = "SELECT * FROM posts WHERE `title` LIKE '%$SearchTerm%' OR `content` LIKE '%$SearchTerm%'";
SELECT
*
FROM
posts
WHERE
lower(`title`) LIKE '%android%'
OR lower(`content`) LIKE '%android%'
這是否意味着lettercase不被忽略? – Michelle 2012-04-09 10:32:38
您可以考慮使用全文搜索對多列搜索。這將是快速.http://devzone.zend.com/26/using-mysql-full-text-searching/ – 2012-04-09 10:39:28
謝謝@Pushpesh我會試一試 – Michelle 2012-04-09 12:21:39
@Pushpesh'使用的表類型不支持FULLTEXT索引' – Michelle 2012-04-09 12:49:44