Sorting DB Results
| From: | Ralph Guzman | Date: | Thu, 13 Nov 2003 07:56:35 +0000 |
| Subject: | Sorting DB Results | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-169444@lists.php.net to get a copy of this message | ||
I am trying to write a query (mysql 3.23) that will sort results using one
or two substrings in item number. So for example I have item numbers that
start with SE0000, TS0000, N00000, W000000, etc.
So let say I want results sorted in the following order
TS0000, SE0000, N00000, W00000
I have tried the following in my query but it's not sorting properly:
ORDER BY FIELD(LEFT(item_number, 2) , 'TS'), FIELD(LEFT(item_number, 1)
'N','W')
So my question is, should I put results in an array, then sort the array
instead of trying to sort from mysql?