sql: LIKE
| From: | venome at gmx dot net | Date: | Thu, 11 Jan 2001 07:21:32 +0000 |
| Subject: | sql: LIKE | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-5792@lists.php.net to get a copy of this message | ||
> is there a way to sort the results of a ".. LIKE" query by hits?
i'm sorry i have
1. misunderstood the effect of LIKE
2. posted a question easy to get wrong
so, what i need to know is:
how can i sort the results of "SELECT * FROM foo WHERE bar LIKE
'%searchterm%'" or a similar search query by their "likeness" or by
accuracy, or by
the number of occurence, in order to have the "best" search results on top?
i.e. table 'foo':
bar
---------------------------
'bar'
'have you seen the foo?'
'foo'
'tomatoes are delicious'
'the foo is a foo is a foo'
"SELECT bar FROM foo WHERE bar LIKE '%foo%'" should return something like
the order
bar
---------------------------
'foo' (exact match)
'the foo is a foo is a foo' (3 matches)
'have you seen the foo?' (1 match)
--
Sent through GMX FreeMail - http://www.gmx.net