# make ranking on search result

**URL:** <https://forums.percona.com/t/make-ranking-on-search-result/2045>\
**Category:** LAMP Stack\
**Created:** [June 18, 2008, 12:59am UTC](https://forums.percona.com/t/make-ranking-on-search-result/2045 "2008-06-18T00:59:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![larvus](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@larvus](https://forums.percona.com/u/larvus)\
**Post date:** [June 18, 2008, 12:59am UTC](https://forums.percona.com/t/make-ranking-on-search-result/2045/1 "2008-06-18T00:59:38Z")

</div>

i hv a product table chemicals(prodname,prodcat,proddesc)

my query is

SELECT prodname FROM bw\_product WHERE

prodname like ‘%sodium chloride%’

```
		 OR

```

prodcateg like ‘%sodium chloride%’

```
		 OR 

```

proddesc like ‘%sodium chloride%’

order by prodname

“sodium chloride” is searched ,  
I am getting a very large number of results and the product “sodium chloride” is nowhere near the top.  
The search needs to be configured so that exact (or nearly exact) “prodname” appear at the top,exact (or nearly exact) “prodcateg” appear at the next level and the lowest “ranked” results (ones at bottom) should be ones that had a search hit in the “proddesc” field.

how can i possible these ? pls give the correct query

---

<div class="post-metadata">

**Author:** ![debug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/debug/32/772_2.png) [@debug](https://forums.percona.com/u/debug)\
**Post date:** [June 19, 2008, 1:38am UTC](https://forums.percona.com/t/make-ranking-on-search-result/2045/2 "2008-06-19T01:38:54Z")

</div>

Maybe something like this:

SELECT prodname,2 as sort\_id FROM bw\_product WHERE prodname like ‘%sodium chloride%’  
UNION  
SELECT prodname,2 as sort\_id FROM bw\_product WHERE prodcateg like ‘%sodium chloride%’  
UNION  
SELECT prodname,3 as sort\_id FROM bw\_product WHERE proddesc like ‘%sodium chloride%’  
ORDER by sort\_id;

---

<div class="post-metadata">

**Author:** ![larvus](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@larvus](https://forums.percona.com/u/larvus)\
**Post date:** [June 21, 2008, 8:32am UTC](https://forums.percona.com/t/make-ranking-on-search-result/2045/3 "2008-06-21T08:32:51Z")

</div>

its working

thanks u very much
