开发者

order by result search?

if have in database words nice car, nice, nice, nice car and we searched word nice: how can ORDER BY (listed) those like : nice, nice, nice car, nice car or if searched word nice car ORDER BY(listed) like: nice car, nice car, nice, nice ?

  • words in database : nice car, nice, nice, nice car
  • nice => nice, nice, nice car, nice car
  • nice car => nice car, nice car, nice, nice

my query:

$find = $this->input->post('find');
    $where 开发者_如何学Python =   "name LIKE '%$find%' OR 
            star LIKE '%$find%' OR
            address LIKE '%$find%'";
$query = $data['results'] = $this->db->query("SELECT @rownum:=@rownum+1 rownum, t.*
        FROM (
        SELECT *
        FROM my_table
        WHERE 
            $where
        ORDER BY id desc
        LIMIT $offset, $coun_page       
        ) t,
        (SELECT @rownum:=0) r");


MySQL is not a search engine. I'd highly recommend using something that actually is for this task (e.g. Sphinx, Solr, or Lucene).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜