SHARE
TWEET

Dropdown Country City - SQL

gridphp Aug 6th, 2014 36 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. DROP TABLE IF EXISTS `city`;
  3.  
  4. CREATE TABLE `city` (
  5.   `id` INT(11) NOT NULL AUTO_INCREMENT,
  6.   `name` VARCHAR(255) DEFAULT NULL,
  7.   `state_id` INT(11) DEFAULT NULL,
  8.   PRIMARY KEY (`id`)
  9. ) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;
  10.  
  11. /*Data for the table `city` */
  12.  
  13. INSERT  INTO `city`(`id`,`name`,`state_id`) VALUES (1,'Karachi',4);
  14. INSERT  INTO `city`(`id`,`name`,`state_id`) VALUES (2,'Hyderabad',4);
  15. INSERT  INTO `city`(`id`,`name`,`state_id`) VALUES (3,'Khotki',4);
  16. INSERT  INTO `city`(`id`,`name`,`state_id`) VALUES (4,'Jamshoro',4);
  17. INSERT  INTO `city`(`id`,`name`,`state_id`) VALUES (5,'Lahore',5);
  18. INSERT  INTO `city`(`id`,`name`,`state_id`) VALUES (6,'Bahalwarpur',5);
  19. INSERT  INTO `city`(`id`,`name`,`state_id`) VALUES (7,'Islamabad',5);
  20. INSERT  INTO `city`(`id`,`name`,`state_id`) VALUES (8,'Los Angeles',3);
  21. INSERT  INTO `city`(`id`,`name`,`state_id`) VALUES (9,'San Diego',3);
  22. INSERT  INTO `city`(`id`,`name`,`state_id`) VALUES (10,'San Francisco',3);
  23. INSERT  INTO `city`(`id`,`name`,`state_id`) VALUES (11,'Juneau',2);
  24. INSERT  INTO `city`(`id`,`name`,`state_id`) VALUES (12,'Fairbanks',2);
  25. INSERT  INTO `city`(`id`,`name`,`state_id`) VALUES (13,'Anchorage',2);
  26. INSERT  INTO `city`(`id`,`name`,`state_id`) VALUES (14,'Aurora',1);
  27. INSERT  INTO `city`(`id`,`name`,`state_id`) VALUES (15,'Austin',1);
  28. INSERT  INTO `city`(`id`,`name`,`state_id`) VALUES (16,'Houston',1);
  29.  
  30. /*Table structure for table `country` */
  31.  
  32. DROP TABLE IF EXISTS `country`;
  33.  
  34. CREATE TABLE `country` (
  35.   `id` INT(11) NOT NULL AUTO_INCREMENT,
  36.   `name` VARCHAR(255) DEFAULT NULL,
  37.   PRIMARY KEY (`id`)
  38. ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
  39.  
  40. /*Data for the table `country` */
  41.  
  42. INSERT  INTO `country`(`id`,`name`) VALUES (1,'United States');
  43. INSERT  INTO `country`(`id`,`name`) VALUES (2,'Pakistan');
  44.  
  45. /*Table structure for table `state` */
  46.  
  47. DROP TABLE IF EXISTS `state`;
  48.  
  49. CREATE TABLE `state` (
  50.   `id` INT(11) NOT NULL AUTO_INCREMENT,
  51.   `name` VARCHAR(255) DEFAULT NULL,
  52.   `country_id` INT(11) DEFAULT NULL,
  53.   PRIMARY KEY (`id`)
  54. ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
  55.  
  56. /*Data for the table `state` */
  57.  
  58. INSERT  INTO `state`(`id`,`name`,`country_id`) VALUES (1,'Texas',1);
  59. INSERT  INTO `state`(`id`,`name`,`country_id`) VALUES (2,'Alaska',1);
  60. INSERT  INTO `state`(`id`,`name`,`country_id`) VALUES (3,'California',1);
  61. INSERT  INTO `state`(`id`,`name`,`country_id`) VALUES (4,'Sind',2);
  62. INSERT  INTO `state`(`id`,`name`,`country_id`) VALUES (5,'Punjab',2);
  63.  
  64. /*Table structure for table `store` */
  65.  
  66. DROP TABLE IF EXISTS `store`;
  67.  
  68. CREATE TABLE `store` (
  69.   `id` INT(11) NOT NULL AUTO_INCREMENT,
  70.   `city_id` INT(11) DEFAULT NULL,
  71.   `name` VARCHAR(255) DEFAULT NULL,
  72.   `country_id` INT(11) DEFAULT NULL,
  73.   `state_id` INT(11) DEFAULT NULL,
  74.   PRIMARY KEY (`id`)
  75. ) ENGINE=InnoDB AUTO_INCREMENT=95 DEFAULT CHARSET=utf8;
  76.  
  77. /*Data for the table `store` */
  78.  
  79. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (1,1,'Karachi Store 3',2,4);
  80. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (2,2,'Hyderabad Store 3',2,4);
  81. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (3,3,'Khotki Store 3',2,4);
  82. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (4,4,'Jamshoro Store 3',2,4);
  83. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (5,5,'Lahore Store 3',2,5);
  84. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (6,6,'Bahalwarpur Store 3',2,5);
  85. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (7,7,'Islamabad Store 3',2,5);
  86. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (8,8,'Los Angeles Store 3',1,3);
  87. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (9,9,'San Diego Store 3',1,3);
  88. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (10,10,'San Francisco Store 3',1,3);
  89. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (11,11,'Juneau Store 3',1,2);
  90. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (12,12,'Fairbanks Store 3',1,2);
  91. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (13,13,'Anchorage Store 3',1,2);
  92. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (14,14,'Aurora Store 3',1,1);
  93. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (15,15,'Austin Store 3',1,1);
  94. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (16,16,'Houston Store 3',1,1);
  95. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (32,1,'Karachi Store 1',2,4);
  96. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (33,2,'Hyderabad Store 1',2,4);
  97. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (34,3,'Khotki Store 1',2,4);
  98. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (35,4,'Jamshoro Store 1',2,4);
  99. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (36,5,'Lahore Store 1',2,5);
  100. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (37,6,'Bahalwarpur Store 1',2,5);
  101. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (38,7,'Islamabad Store 1',2,5);
  102. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (39,8,'Los Angeles Store 1',1,3);
  103. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (40,9,'San Diego Store 1',1,3);
  104. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (41,10,'San Francisco Store 1',1,3);
  105. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (42,11,'Juneau Store 1',1,2);
  106. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (43,12,'Fairbanks Store 1',1,2);
  107. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (44,13,'Anchorage Store 1',1,2);
  108. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (45,14,'Aurora Store 1',1,1);
  109. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (46,15,'Austin Store 1',1,1);
  110. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (47,16,'Houston Store 1',1,1);
  111. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (63,1,'Karachi Store 2',2,4);
  112. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (64,2,'Hyderabad Store 2',2,4);
  113. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (65,3,'Khotki Store 2',2,4);
  114. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (66,4,'Jamshoro Store 2',2,4);
  115. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (67,5,'Lahore Store 2',2,5);
  116. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (68,6,'Bahalwarpur Store 2',2,5);
  117. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (69,7,'Islamabad Store 2',2,5);
  118. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (70,8,'Los Angeles Store 2',1,3);
  119. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (71,9,'San Diego Store 2',1,3);
  120. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (72,10,'San Francisco Store 2',1,3);
  121. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (73,11,'Juneau Store 2',1,2);
  122. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (74,12,'Fairbanks Store 2',1,2);
  123. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (75,13,'Anchorage Store 2',1,2);
  124. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (76,14,'Aurora Store 2',1,1);
  125. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (77,15,'Austin Store 2',1,1);
  126. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (78,16,'Houston Store 2',1,1);
  127. INSERT  INTO `store`(`id`,`city_id`,`name`,`country_id`,`state_id`) VALUES (94,5,'Super Store Lahore ',2,5);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top