查询搜索引擎

时间:2015-10-29 23:15:13

标签: jquery mysqli

我试图做搜索引擎。

我想从BandSong_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)."%'" ;

1 个答案:

答案 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)."%'
";