MySQL State Names and Codes

Download SQL country-region state/province name and code database table

State Names List SQL Code

This is the SQL database table structure of the code list of states' names.

The list has about 5000 lines of state names, not all lines can be shown here. So you can download it by clicking the download button below.

SQL
CREATE TABLE IF NOT EXISTS `states` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `state_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `state_code` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `country_code` varchar(3) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4949 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `states`
--

INSERT INTO `states` (`id`, `state_name`, `state_code`, `country_code`) VALUES
(1, 'Badakhshan', 'BDS', 'AF'),
(2, 'Badghis', 'BDG', 'AF'),
(3, 'Baghlan', 'BGL', 'AF'),
(4, 'Balkh', 'BAL', 'AF'),
(5, 'Bamyan', 'BAM', 'AF'),
(6, 'Daykundi', 'DAY', 'AF'),
(7, 'Farah', 'FRA', 'AF'),
(8, 'Faryab', 'FYB', 'AF'),
(9, 'Ghazni', 'GHA', 'AF'),
(10, 'Ghōr', 'GHO', 'AF'),
...

SQL State Name Query Statement Example

You can select the list of all state names in that country using the country code you want.

The following SQL statement selects the "state name" and "state code" columns from the "state" table. By country code

SQL
-- India country code "IN" 
SELECT `state_name`, `state_code` FROM `states` WHERE `country_code` = 'IN';

-- United States
-- SELECT `state_name`, `state_code` FROM `states` WHERE `country_code` = 'US';