如何在多列中搜索字词:title
,content
。例如:
$searchTerm = 'android';
SELECT * FROM posts WHERE `title` OR `content` contains $SearchTerm
答案 0 :(得分:1)
SELECT
*
FROM
posts
WHERE
lower(`title`) LIKE '%android%'
OR lower(`content`) LIKE '%android%'
答案 1 :(得分:0)
SELECT *
FROM posts
WHERE
`title` LIKE '%android%'
OR `content` LIKE '%android%'
答案 2 :(得分:0)
$sql = "SELECT * FROM posts WHERE `title` LIKE '%$SearchTerm%' OR `content` LIKE '%$SearchTerm%'";