我正在我的博客上组装一个搜索框。默认情况下,脚本如下:
$sql = "SELECT id, title FROM topics WHERE message LIKE '%" . $description . "%' ORDER BY message LIMIT 10";
此脚本仅搜索邮件行中的数据。我想添加另一行。例如title
。
我在希望关键字中修改了这样的脚本将跟踪消息行和标题:
$sql = "SELECT id, title FROM topics WHERE message, title LIKE '%" . $description . "%' ORDER BY message, title LIMIT 10";
原来它不起作用。应该怎么做?
答案 0 :(得分:1)
我认为这可能是你正在寻找的东西
"SELECT id, title FROM topics WHERE message LIKE '%" . $description . "%' or title LIKE '%" . $description . "%' ORDER BY message, title LIMIT 10";
答案 1 :(得分:1)
尝试此查询...
$sql = "SELECT id, title FROM topics WHERE message LIKE '%$description%' OR title LIKE '%$description%' ORDER BY message, title LIMIT 10";