hi all...

i have a mysql query as follows:

    SELECT *,

    ( if((description LIKE '%keyword_one%'), 1, 0)+
    if((description LIKE '%keyword_two%'), 1, 0)+
    if((description LIKE '%keyword_three%'), 1, 0)+
    if((description LIKE '%keyword_four%'), 1, 0) ) as keyword_score,

    FROM table WHERE

    ( (description LIKE '%keyword_one%) OR
    (description LIKE '%keyword_two%) OR
    (description LIKE '%keyword_three%) OR
    (description LIKE '%keyword_four%) )

    GROUP BY ref ORDER BY keyword_score DESC;

this query is great for my search engine because it ranks the results based
on how many keywords were found in each row (users love this).

i know have to think about making it portable (i found the if() statement
didnt work in PostgreSQL).

are there any portable equivilents to this MySQL specific query?

thanks for your thoughts,

jamie burns.


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to