Re: Sorting MySQL queries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/5/06, Roman Neuhauser <neuhauser@xxxxxxxxxx> wrote:

    If you used PostgreSQL I'd suggest a functional index and ordering
    on the function... Does MySQL have anything like this?

    CREATE FUNCTION fn(TEXT)
    RETURNS TEXT
    IMMUTABLE STRICT
    LANGUAGE SQL
    AS $$
      SELECT regexp_replace($1, '^(?:(?:a|the)[[:space:]]+)', '', 'i');
    $$;

    CREATE INDEX ON table(fn(subject));

Thats rather nifty, i dont think you can do that with mysql, but you
could achieve something close to that with a trigger for insert/update
to apply the regex to a different field that is used for sorting.

The other option would make a policy to put ", The" or ", A" at the
end of the string a simple function to render the text without the
comma at the end would be simple to do.

Curt

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux