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 EngineerSafe Data, Inc. (910) 285-7200 [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: Packing list sort
David Ruggles schrieb: 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 | +--+-++ you need to add an additional field like 'priority' and do ORDER BY priority DESC, species ASC -- Sebastian -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
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:[EMAIL PROTECTED] 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 EngineerSafe Data, Inc. (910) 285-7200 [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Packing list sort
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:[EMAIL PROTECTED] 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:[EMAIL PROTECTED] 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 EngineerSafe Data, Inc. (910) 285-7200 [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Packing list sort
Thank you very much, that seems very simple now that I see it. Thanks, David Ruggles CCNA MCSE (NT) CNA A+ Network EngineerSafe Data, Inc. (910) 285-7200 [EMAIL PROTECTED] -Original Message- From: Rolando Edwards [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 22, 2008 10:26 AM To: David Ruggles; 'mysql' Subject: RE: Packing list sort 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:[EMAIL PROTECTED] 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:[EMAIL PROTECTED] 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 EngineerSafe Data, Inc. (910) 285-7200 [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]