Ayuda por que me muestra datos erróneos
Publicado por Pepe (10 intervenciones) el 31/08/2020 19:13:09
Hola buenas tengo esta estructura de tabla
con los siguientes datos
Quisiera saber por que me da datos incorrectos esta consulta
Me muestra datos del id 4, no entiendo por que me muestra los datos incorrectos. Si alguien me pudiera ayudar a ver el error que tengo
con los siguientes datos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
--
-- Estructura de tabla para la tabla `tipo_ext`
--
CREATE TABLE IF NOT EXISTS `tipo_ext` (
`id` tinyint(4) NOT NULL AUTO_INCREMENT,
`tipo` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
--
-- Volcado de datos para la tabla `tipo_ext`
--
INSERT INTO `tipo_ext` (`id`, `tipo`) VALUES
(1, 'Numerica'),
(2, 'Larga'),
(3, 'Corta'),
(4, 'Cora');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `t_ag`
--
CREATE TABLE IF NOT EXISTS `t_ag` (
`id` tinyint(4) NOT NULL AUTO_INCREMENT,
`nombre` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;
--
-- Volcado de datos para la tabla `t_ag`
--
INSERT INTO `t_ag` (`id`, `nombre`) VALUES
(1, 'PruebaAG1'),
(2, 'PruebaAG1'),
(3, 'PruebaAG2'),
(4, 'PruebaAG3'),
(5, 'PruebaAG4');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `t_ext`
--
CREATE TABLE IF NOT EXISTS `t_ext` (
`id` tinyint(4) NOT NULL AUTO_INCREMENT,
`ext` varchar(10) DEFAULT NULL,
`tipoExt` varchar(10) DEFAULT NULL,
`id_meg` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=15 ;
--
-- Volcado de datos para la tabla `t_ext`
--
INSERT INTO `t_ex` (`id`, `ext`, `tipoExt`, `id_meg`) VALUES
(10, 'd2345', '1', '2'),
(11, 'd345534', '1', '3'),
(12, 'd344444', '2', '3'),
(13, 'd643333', '4', '4'),
(14, '45566', '3', '4');
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `t_meg`
--
CREATE TABLE IF NOT EXISTS `t_meg` (
`id` tinyint(4) NOT NULL AUTO_INCREMENT,
`nombre` varchar(10) DEFAULT NULL,
`id_ag` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
--
-- Volcado de datos para la tabla `t_meg`
--
INSERT INTO `t_meg` (`id`, `nombre`, `id_ag`) VALUES
(1, 'PruebaMEG1', '1'),
(2, 'PruebaMEG2', '3'),
(3, 'PruebaMEG3', '4'),
(4, 'PruebaMEG4', '4');
Quisiera saber por que me da datos incorrectos esta consulta
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
select
t_ext.id,
extension,
id_meg,
tipo_ext.tipo as tipoExtension,
t_meg.nombre as nombreMEG,
t_ag.nombre as nombreAG,
t_ag.id as idAG
from
t_ext
left join tipo_ext on tipo_ext.id = t_ext.tipoExt
left join t_meg on t_meg.id = t_ext.id_mg
left join t_ag on t_ag.id= t_mg.id
where t_ag.id=3
Me muestra datos del id 4, no entiendo por que me muestra los datos incorrectos. Si alguien me pudiera ayudar a ver el error que tengo
Valora esta pregunta


0