--- James Keeline <[EMAIL PROTECTED]> wrote:

> You could use two queries with a UNION statement:
> 
> SELECT * FROM table WHERE LEFT(sortfield,1) REGEX '[0-9]' ORDER BY sortfield
> UNION
> SELECT * FROM table WHERE !(LEFT(sortfield,1) REGEX '[0-9]') ORDER BY
> sortfield;
> 
> I haven't tested the above but it should be pretty close.  If your version of
> MySQL does not support REGEX then look at RLIKE.
> 
> James Keeline

My sample above would do the numbers first and then the letters.  Switching the
two SELECT statements should provide the desired result.

SELECT * FROM table WHERE !(LEFT(sortfield,1) REGEX '[0-9]') ORDER BY sortfield
UNION
SELECT * FROM table WHERE LEFT(sortfield,1) REGEX '[0-9]' ORDER BY sortfield;

James Keeline

Reply via email to