Try "MATCH (FULLTEXT index columns) AGAINST ('keyword')"

Check the MySQL manual at: <http://www.mysql.com> and search for "match 
against" or "fulltext"
You need to build FULLTEXT indexes on the columns you want to search 
before you can use the above syntax.

However, it will search and sort by relevance.


On Thursday, April 19, 2001, at 09:56 AM, Jen Hall wrote:

> Hi there
> I have some scripts that do a search in a MySQL database
> table.
> I want to be able to return rows that match a query, in
> order of relevancy.
> For example, say I have a table that has the following data
>
> |row_id|  data
> |------|-------------------------------------
> |  1   |  cat
> |  2   |  cat cat
> |  3   |  cat cat cat
> |  4   |  cat cat
> |  5   |  cat cat cat cat cat cat cat
> |  6   |  cat
> |  7   |  cat cat cat cat
> |  8   |  cat cat cat cat cat
>
> I want to do a search that would return row_id 5 first, then
>
> row_id 8, then row_id 7, then 3, etc.
> So I want to order the return by relevancy.
> What should the sql query look like?
> select * from table where data like '%cat%' order by ?????
>
> thanks
> -jen

--
Clarence

-> [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to