|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
From: Rolando Edwards (redwards
logicworks.net)
Date: Tue Jan 22 2008 - 09:25:38 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Try One of These (including name):
SELECT name,species,birth FROM animals ORDER BY IF(species='hamster',0,1),species,name;
OR
SELECT name,species,birth FROM
(SELECT name,species,birth,IF(species='hamster',0,1) sortorder
FROM animals) A ORDER BY sortorder,species,name;
-----Original Message-----
From: Rolando Edwards [mailto:redwards
logicworks.net]
Sent: Tuesday, January 22, 2008 10:23 AM
To: David Ruggles; 'mysql'
Subject: RE: Packing list sort
Try One of These:
SELECT name,species,birth FROM animalsORDER BY IF(species='hamster',0,1),species;
OR
SELECT name,species,birth FROM
(SELECT name,species,birth,IF(species='hamster',0,1) sortorder
FROM animals) A ORDER BY sortorder,species;
-----Original Message-----
From: David Ruggles [mailto:david
safedatausa.com]
Sent: Tuesday, January 22, 2008 9:53 AM
To: 'mysql'
Subject: Packing list sort
I have googled, read the mysql documentation and searched the list archive.
I don't know if I just don't know the correct term to use or if I have some
other problem.
In a nutshell I generate packing lists where the items are normally sorted
alphabetically. However, there is one type of item that always gets loaded
first. I would like for any of these items to always be at the top of the
list. Here's the classic animal example:
Given:
+----------+---------+------------+
| name | species | birth |
+----------+---------+------------+
| Chirpy | bird | 1998-09-11 |
| Whistler | bird | 1997-12-09 |
| Claws | cat | 1994-03-17 |
| Fluffy | cat | 1993-02-04 |
| Fang | dog | 1990-08-27 |
| Bowser | dog | 1989-08-31 |
| Buffy | dog | 1989-05-13 |
| Puffball | hamster | 1999-03-30 |
| Slim | snake | 1996-04-29 |
+----------+---------+------------+
I want hamsters to always sort out first, but still have everything else in
alphabetical order
Like this:
+----------+---------+------------+
| name | species | birth |
+----------+---------+------------+
| Puffball | hamster | 1999-03-30 |
| Chirpy | bird | 1998-09-11 |
| Whistler | bird | 1997-12-09 |
| Claws | cat | 1994-03-17 |
| Fluffy | cat | 1993-02-04 |
| Fang | dog | 1990-08-27 |
| Bowser | dog | 1989-08-31 |
| Buffy | dog | 1989-05-13 |
| Slim | snake | 1996-04-29 |
+----------+---------+------------+
Thanks,
David Ruggles
CCNA MCSE (NT) CNA A+
Network Engineer Safe Data, Inc.
(910) 285-7200 david
safedatausa.com
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=redwards
logicworks.net
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=redwards
logicworks.net
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]