开发者

order by result search?

开发者 https://www.devze.com 2023-03-29 00:38 出处:网络
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)

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

精彩评论

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