Thank you Roger! :) This works well for me! ^_^
Thanks also to the other guys that I replied. :)
Ang sabi sa akin ni Roger Baklund noong 06:12 AM 5/10/2005...
"This way" and only four rows in the example is a bit vague, but maybe
something like this could work for you:
$crit = 'Ang'; # test case
SELECT name
FROM t1
WHERE name like '%crit%'
ORDER BY
name != '$crit', # exact match
name not like '$crit %', # first word
name not like '% $crit', # last word
name not like '$crit%', # start of first word
name not like '% $crit%', # start of non-first word
name # alphabetically
Some of these are not in your example, I was just guessing... but you get
the idea. Each expression in the ORDER BY clause returns 0 (false) or 1
(true). Because 0 is smaller than 1, and ASC is the default sorting order,
we want each expression to be FALSE, so that it is sorted first. That's
why I negated all expressions. An alternative would be to use DESC after
each expression.
--
Roger
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]