Guest User

Untitled

a guest
Jan 18th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. CREATE TABLE `cities` (
  2. `id` int(11) NOT NULL,
  3. `city` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
  4. `state_code` char(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
  5. `state_id` int(11) NOT NULL DEFAULT '0'
  6. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  7.  
  8. --
  9. -- Indexes for dumped tables
  10. --
  11.  
  12. --
  13. -- Indexes for table `cities`
  14. --
  15. ALTER TABLE `cities`
  16. ADD PRIMARY KEY (`id`);
  17.  
  18. --
  19. -- AUTO_INCREMENT for dumped tables
  20.  
  21.  
  22. -- --------------------------------------------------------
  23.  
  24. --
  25. -- Table structure for table `cities_extended`
  26. --
  27.  
  28. CREATE TABLE `cities_extended` (
  29. `id` int(11) NOT NULL,
  30. `city` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
  31. `state_code` char(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
  32. `zip` int(5) UNSIGNED ZEROFILL NOT NULL,
  33. `latitude` double NOT NULL,
  34. `longitude` double NOT NULL,
  35. `county` varchar(50) NOT NULL,
  36. `state_id` int(11) NOT NULL DEFAULT '0',
  37. `city_id` int(11) NOT NULL DEFAULT '0'
  38. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  39.  
  40. --
  41. -- Indexes for dumped tables
  42. --
  43.  
  44. --
  45. -- Indexes for table `cities_extended`
  46. --
  47. ALTER TABLE `cities_extended`
  48. ADD PRIMARY KEY (`id`);
  49.  
  50. --
  51. -- AUTO_INCREMENT for dumped tables
  52. --
  53.  
  54. --
  55. -- AUTO_INCREMENT for table `cities_extended`
  56. --
  57. ALTER TABLE `cities_extended`
  58. MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;COMMIT;
  59.  
  60. UPDATE
  61. cities_extended
  62. SET
  63. cities_extended.`city_id` = cities.`id`
  64. FROM
  65. cities_extended
  66. INNER JOIN
  67. cities
  68. ON
  69. cities_extended.`state_id` = cities.`state_id`
  70. AND
  71. cities_extended.`city`= cities.`city`
Add Comment
Please, Sign In to add comment