Home » Performance » LAMP » make ranking on search result
make ranking on search result [message #3192] Wed, 18 June 2008 02:29 Go to next message
larvus  is currently offline larvus
Messages: 5
Registered: June 2008
Location: india
Junior Member

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


Larvus
Re: make ranking on search result [message #3200 is a reply to message #3192 ] Thu, 19 June 2008 03:08 Go to previous messageGo to next message
debug  is currently offline debug
Messages: 111
Registered: March 2008
Senior Member

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;


Mikhail Solovyev, MySQL Performance Expert
MySQL Performance Blog
MySQL Consulting
Re: make ranking on search result [message #3209 is a reply to message #3200 ] Sat, 21 June 2008 10:02 Go to previous message
larvus  is currently offline larvus
Messages: 5
Registered: June 2008
Location: india
Junior Member


its working

thanks u very much


Larvus
Previous Topic:MySQL very slow for big SELECT - Optimize MySQL
Next Topic:mysql tables for nagios
Goto Forum:
  



Current Time: Mon Oct 13 09:04:41 EDT 2008

Total time taken to generate the page: 0.01237 seconds
.:: Contact :: Home :: MySQL Support by Percona.com ::.

Powered by: FUDforum 2.7.5.
Copyright ©2001-2006 FUD Forum Bulletin Board Software

MySQL Performance | Forum authority Badge