Mega Code Archive

 
Categories / MySQL / Select Clause
 

To sort those records in calendar order, use the birthmonth and birthday columns

mysql> mysql> CREATE TABLE Master (     ->   LahmanID char(10) NOT NULL default '',     ->   Lastname char(25) default NULL,     ->   Firstname char(25) default NULL,     ->   Bats char(1) default NULL,     ->   Throws char(1) default NULL,     ->   BirthMonth int(11) default NULL,     ->   BirthDay int(11) default NULL,     ->   BirthYear int(11) default NULL,     ->   Debut int(11) default NULL,     ->   PRIMARY KEY  (LahmanID)     -> ) TYPE=MyISAM; Query OK, 0 rows affected, 1 warning (0.01 sec) mysql> mysql> mysql> SELECT lastname, firstname, birthyear, birthmonth, birthday     -> FROM master     -> WHERE birthmonth IS NOT NULL AND birthday IS NOT NULL     -> ORDER BY birthmonth, birthday, lastname, firstname; Empty set (0.00 sec) mysql> mysql> drop table master; Query OK, 0 rows affected (0.00 sec)