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).
精彩评论