我试图做搜索引擎。
我想从Band
或Song_name
开始时找到结果。但是这个查询只显示结果,然后我从Song_name
开始。这个查询有问题吗?
$query = "SELECT Band, Song_name FROM Songs WHERE
CONCAT(Band,' ',Song_name) OR CONCAT(Song_name,' ',Band)
LIKE '".mysqli_real_escape_string($con, $search_text)."%'" ;
答案 0 :(得分:1)
将WHERE语句更改为以下内容:
$query = "
SELECT
Band, Song_name
FROM
Songs
WHERE
CONCAT(Band,' ',Song_name) LIKE '".mysqli_real_escape_string($con, $search_text)."%'
OR
CONCAT(Song_name,' ',Band) LIKE '".mysqli_real_escape_string($con, $search_text)."%'
";