Ver Mensaje Individual
  #3 (permalink)  
Antiguo 04/04/2010, 17:22
tokkaido
 
Fecha de Ingreso: julio-2009
Mensajes: 90
Antigüedad: 15 años, 5 meses
Puntos: 4
Respuesta: Join de 2 tablas devuelve mas registros de los esperados

Hola, creo que asi se hace, no? pegando aqui

Código MySQL:
Ver original
  1. CREATE TABLE `detalle_vales` (
  2.   `id_interno` int(10) unsigned NOT NULL AUTO_INCREMENT,
  3.   `id_solicitud` int(11) NOT NULL,
  4.   `saliente` int(11) NOT NULL,
  5.   `sal_estado` varchar(10) NOT NULL,
  6.   `sal_ok` bit(1) NOT NULL,
  7.   `sal_medida` int(10) unsigned NOT NULL,
  8.   `entrante` int(50) NOT NULL,
  9.   `ent_estado` varchar(10) NOT NULL,
  10.   `ent_ok` bit(1) NOT NULL,
  11.   `ent_medida` int(11) NOT NULL,
  12.   `fecha_sal` datetime NOT NULL,
  13.   `fecha_ent` datetime NOT NULL,
  14.   PRIMARY KEY (`id_interno`)
  15.  
  16.  
  17. INSERT INTO `detalle_vales` VALUES ('1', '1', '3157', 'Nuevo', '', '1', '3027', 'Usado', '', '11', '2010-04-04 16:16:27', '2010-04-04 16:20:25');
  18. INSERT INTO `detalle_vales` VALUES ('2', '1', '3158', 'Nuevo', '', '6', '3028', 'Usado', '', '11', '2010-04-04 16:16:36', '2010-04-04 16:19:52');
  19. INSERT INTO `detalle_vales` VALUES ('3', '1', '3159', 'Nuevo', '', '6', '2537', 'Usado', '', '11', '2010-04-04 16:20:26', '2010-04-04 16:20:28');
  20.  
  21. CREATE TABLE `detalle_solicitud_cambio` (
  22.   `id_interno` int(10) unsigned NOT NULL AUTO_INCREMENT,
  23.   `id_solicitud` int(10) unsigned NOT NULL,
  24.   `posicion` tinyint(3) unsigned NOT NULL,
  25.   `entrante` smallint(5) unsigned NOT NULL,
  26.   `ent_id` int(10) unsigned NOT NULL,
  27.   `ent_medida` tinyint(4) unsigned NOT NULL,
  28.   `ent_estado` varchar(10) NOT NULL,
  29.   `ent_prof` tinyint(4) unsigned NOT NULL,
  30.   `ent_presion` tinyint(4) unsigned NOT NULL,
  31.   `ent_ok` bit(1) NOT NULL,
  32.   `ent_fecha` datetime NOT NULL,
  33.   `saliente` smallint(5) unsigned NOT NULL,
  34.   `sal_id` int(10) unsigned NOT NULL,
  35.   `sal_medida` tinyint(4) unsigned NOT NULL,
  36.   `sal_estado` varchar(10) NOT NULL,
  37.   `sal_prof` tinyint(4) unsigned NOT NULL,
  38.   `sal_presion` tinyint(3) unsigned NOT NULL,
  39.   `sal_ok` bit(1) NOT NULL,
  40.   `sal_fecha` datetime NOT NULL,
  41.   `condicion` tinyint(3) unsigned NOT NULL,
  42.   `motivo` tinyint(3) unsigned NOT NULL,
  43.   PRIMARY KEY (`id_interno`)
  44.  
  45. INSERT INTO `detalle_solicitud_cambio` VALUES ('1', '1', '1', '3157', '2', '1', 'Nuevo', '25', '0', '', '0000-00-00 00:00:00', '3027', '144', '11', 'Usado', '8', '0', '', '2010-04-04 16:11:35', '3', '4');
  46. INSERT INTO `detalle_solicitud_cambio` VALUES ('2', '1', '2', '3158', '1', '6', 'Nuevo', '26', '0', '', '2010-04-04 16:19:10', '3028', '145', '11', 'Usado', '6', '0', '', '2010-04-04 16:08:28', '4', '2');
  47. INSERT INTO `detalle_solicitud_cambio` VALUES ('3', '1', '3', '3159', '1', '6', 'Nuevo', '26', '0', '', '0000-00-00 00:00:00', '2537', '146', '11', 'Usado', '5', '0', '', '2010-04-04 16:11:09', '4', '3');

gracias de antebrazo, perdon, mano,
__________________
C[^L*]D
[email protected]
tokkaido.blogspot.com
No hay mejor forma de aprender que enseñar