Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 1912

Administration Joomla! 5.x • Re: Step by step to create a list with states and cities with Fields Joomla

$
0
0
I think you should make the `name` field NOT NULL or you have the prospect of having states and cities with null names. So no DEFAULT either. I don' know what `uf` is but that might be NOT NULL too:

Code:

CREATE TABLE `aaaaa_cidades` (  `id` int NOT NULL AUTO_INCREMENT,  `nome` varchar(120) NOT NULL,  `id_estado` int NOT NULL,  PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;CREATE TABLE `aaaaa_estados` (  `id` int NOT NULL AUTO_INCREMENT,  `nome` varchar(75) NOT NULL,  `uf` varchar(5) DEFAULT NULL,  PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;
Replace aaaaa with your own prefix.

5K cities is a lot to choose from in a list select!
I made the recommended corrections and the "kscj5_cidades" table worked very well.

UF is an abbreviation for State officially used in Brazil e.g.: UF= CE (State of Ceará)

Now the error appeared in the kscj5_states table:

MySQL Message: Documentation

#1068 - Defined more than one primary key

This one here:

Code:

CREATE TABLE `kscj5_estados` (  `id` int NOT NULL AUTO_INCREMENT,  `nome` varchar(75) NOT NULL,  `uf` varchar(5) DEFAULT NULL,  PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;---- Extraindo dados da tabela `estados`--INSERT INTO `kscj5_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');---- Índices para tabelas despejadas------ Índices para tabela `cidades`--ALTER TABLE `kscj5_cidades`  ADD PRIMARY KEY (`id`),  ADD KEY `fk_Cidade_estado` (`id_estado`);---- Índices para tabela `estados`--ALTER TABLE `kscj5_estados`  ADD PRIMARY KEY (`id`);---- AUTO_INCREMENT de tabelas despejadas------ AUTO_INCREMENT de tabela `cidades`--ALTER TABLE `kscj5_cidades`  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5565;---- AUTO_INCREMENT de tabela `estados`--ALTER TABLE `kscj5_estados`  MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=28;/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Thank you for your help

Statistics: Posted by rikaryo — Fri May 10, 2024 12:25 am



Viewing all articles
Browse latest Browse all 1912

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>