Posted By

bcalloway on 12/02/08


Tagged

mysql


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

jamesming
robe
rickfu


US States SQL


 / Published in: SQL
 

SQL INSERT query to create a states table

  1. CREATE TABLE IF NOT EXISTS `states` (
  2. `id` int(11) NOT NULL AUTO_INCREMENT,
  3. `abbr` varchar(2) NOT NULL,
  4. `name` varchar(250) NOT NULL,
  5. PRIMARY KEY (`id`)
  6. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=52 ;
  7.  
  8. INSERT INTO `states` (`id`, `abbr`, `name`) VALUES
  9. (1, 'AL', 'Alabama'),
  10. (2, 'AK', 'Alaska'),
  11. (3, 'AZ', 'Arizona'),
  12. (4, 'AR', 'Arkansas'),
  13. (5, 'CA', 'California'),
  14. (6, 'CO', 'Colorado'),
  15. (7, 'CT', 'Connecticut'),
  16. (8, 'DE', 'Delaware'),
  17. (9, 'DC', 'District of Columbia'),
  18. (10, 'FL', 'Florida'),
  19. (11, 'GA', 'Georgia'),
  20. (12, 'HI', 'Hawaii'),
  21. (13, 'ID', 'Idaho'),
  22. (14, 'IL', 'Illinois'),
  23. (15, 'IN', 'Indiana'),
  24. (16, 'IA', 'Iowa'),
  25. (17, 'KS', 'Kansas'),
  26. (18, 'KY', 'Kentucky'),
  27. (19, 'LA', 'Louisiana'),
  28. (20, 'ME', 'Maine'),
  29. (21, 'MD', 'Maryland'),
  30. (22, 'MA', 'Massachusetts'),
  31. (23, 'MI', 'Michigan'),
  32. (24, 'MN', 'Minnesota'),
  33. (25, 'MS', 'Mississippi'),
  34. (26, 'MO', 'Missouri'),
  35. (27, 'MT', 'Montana'),
  36. (28, 'NE', 'Nebraska'),
  37. (29, 'NV', 'Nevada'),
  38. (30, 'NH', 'New Hampshire'),
  39. (31, 'NJ', 'New Jersey'),
  40. (32, 'NM', 'New Mexico'),
  41. (33, 'NY', 'New York'),
  42. (34, 'NC', 'North Carolina'),
  43. (35, 'ND', 'North Dakota'),
  44. (36, 'OH', 'Ohio'),
  45. (37, 'OK', 'Oklahoma'),
  46. (38, 'OR', 'Oregon'),
  47. (39, 'PA', 'Pennsylvania'),
  48. (40, 'RI', 'Rhode Island'),
  49. (41, 'SC', 'South Carolina'),
  50. (42, 'SD', 'South Dakota'),
  51. (43, 'TN', 'Tennessee'),
  52. (44, 'TX', 'Texas'),
  53. (45, 'UT', 'Utah'),
  54. (46, 'VT', 'Vermont'),
  55. (47, 'VA', 'Virginia'),
  56. (48, 'WA', 'Washington'),
  57. (49, 'WV', 'West Virginia'),
  58. (50, 'WI', 'Wisconsin'),
  59. (51, 'WY', 'Wyoming');

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Scooter on December 21, 2008

Since this table isn't likely to change very often, you'll also want to cache it in memory to reduce the number of SQL queries against mostly static information.

You need to login to post a comment.