· 6 years ago · Jun 25, 2019, 11:04 PM
1CREATE TABLE IF NOT EXISTS `produto` (
2 `id` int(11) NOT NULL AUTO_INCREMENT,
3 `id_categoria` text,
4 `titulo` text,
5 `referencia` text,
6 `valor` decimal(10,0) DEFAULT NULL,
7 `imagem_principal` text,
8 `descricao` text,
9 `data` text,
10 `status` int(11) DEFAULT NULL,
11 PRIMARY KEY (`id`)
12) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=3 ;
13
14
15INSERT INTO `produto` (`id`, `id_categoria`, `titulo`, `referencia`, `valor`, `imagem_principal`, `descricao`, `data`, `status`) VALUES
16(1, '5', '4Y1A7316-S169', '4Y1A7316-S169', '0', 'd6663aa43c2c044e90375d312b601599.png', '<p>Pincel para Cílios </p>', '2019-04-17 18:02:24', 0),
17(2, '5', '5Y1A7316-S621', '5Y1A7316-S621', '0', '7f699d3c34fd63b8810b1a457404c317.png', '<p>5Y1A7316-S621<br></p>', '2019-04-22 17:47:24', 0);
18
19
20CREATE TABLE IF NOT EXISTS `produto_categoria` (
21 `id` int(11) NOT NULL AUTO_INCREMENT,
22 `id_categoria` text,
23 `titulo` text,
24 `ordem` text,
25 PRIMARY KEY (`id`)
26) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=13 ;
27
28
29INSERT INTO `produto_categoria` (`id`, `id_categoria`, `titulo`, `ordem`) VALUES
30(1, '0', 'Cílios', '0'),
31(2, '0', 'Pentes', '2'),
32(3, '0', 'Toucas', '4'),
33(4, '1', 'Fio a Fio', '0'),
34(5, '1', '3D', '1'),
35(6, '0', 'Pinças', '0'),
36(7, '0', 'Pincéis', '0'),
37(8, '0', 'Tesouras', '0'),
38(9, '0', 'Unhas', '0'),
39(10, '0', 'Esponjas', '0'),
40(11, '0', 'Espátula', '0'),
41(12, '0', 'Alicates', '0');
42
43SELECT * FROM `produto`
44LEFT JOIN `produto_categoria` ON `produto_categoria`.`id`=`produto`.`id_categoria`
45WHERE `produto_categoria`.`id` = '1'`