I previously quoted the query I used to test my answer. Here is my dump of the states table after making adjustments:
You can adjust table structure from within phpMyAdmin. For example, you can add (or remove) keys. The cities table needs index keys on `nome` and `id_estado`.
Code:
-- phpMyAdmin SQL Dump-- version 5.2.0-- https://www.phpmyadmin.net/---- Host: localhost-- Generation Time: May 10, 2024 at 04:39 AM-- Server version: 8.0.33-- PHP Version: 8.3.1SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";SET time_zone = "+00:00";---- Database: `jdm3`---- ------------------------------------------------------------ Table structure for table `aaaaa_estados`--CREATE TABLE `aaaaa_estados` ( `id` int NOT NULL, `nome` varchar(75) COLLATE utf8mb4_unicode_ci NOT NULL, `uf` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;---- Dumping data for table `aaaaa_estados`--INSERT INTO `aaaaa_estados` (`id`, `nome`, `uf`) VALUES(1, 'Acre', 'AC'),(2, 'Alagoas', 'AL'),(3, 'Amazonas', 'AM'),(4, 'Amapá', 'AP'),(5, 'Bahia', 'BA'),(6, 'Ceará', 'CE'),(7, 'Distrito Federal', 'DF'),(8, 'Espírito Santo', 'ES'),(9, 'Goiás', 'GO'),(10, 'Maranhão', 'MA'),(11, 'Minas Gerais', 'MG'),(12, 'Mato Grosso do Sul', 'MS'),(13, 'Mato Grosso', 'MT'),(14, 'Pará', 'PA'),(15, 'Paraíba', 'PB'),(16, 'Pernambuco', 'PE'),(17, 'Piauí', 'PI'),(18, 'Paraná', 'PR'),(19, 'Rio de Janeiro', 'RJ'),(20, 'Rio Grande do Norte', 'RN'),(21, 'Rondônia', 'RO'),(22, 'Roraima', 'RR'),(23, 'Rio Grande do Sul', 'RS'),(24, 'Santa Catarina', 'SC'),(25, 'Sergipe', 'SE'),(26, 'São Paulo', 'SP'),(27, 'Tocantins', 'TO');---- Indexes for dumped tables------ Indexes for table `aaaaa_estados`--ALTER TABLE `aaaaa_estados` ADD PRIMARY KEY (`id`), ADD KEY `nome` (`nome`);---- AUTO_INCREMENT for dumped tables------ AUTO_INCREMENT for table `aaaaa_estados`--ALTER TABLE `aaaaa_estados` MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=28;
Statistics: Posted by ceford — Fri May 10, 2024 4:47 am