Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/10/2006, 16:24
gazuzax
 
Fecha de Ingreso: septiembre-2006
Mensajes: 196
Antigüedad: 17 años, 7 meses
Puntos: 0
Gente Sabia Responda Esto

tengo una relacion de 1,n - 1,n entre tabla COMPUTADORy tabla PARTE que me genero una tabla intermedia USA
Código:
/* Table: COMPUTADOR                                            */
create table if not exists COMPUTADOR
(
   ID_COM                         int                            not null AUTO_INCREMENT,
   ID_SALA                        int                            not null,
   INGRESO_COM                    varchar(50),
   GARANTIA_COM                   varchar(20),
   primary key (ID_COM)
);

/* Table: USA         SE CREO SOLA X LA RELACION 1,N - 1,N                    */
create table if not exists USA
(
   ID_PAR                         int                            not null,
   ID_COM                         int                            not null,
   primary key (ID_PAR, ID_COM)
);

/* Table: PARTE                                                 */
create table if not exists PARTE
(
   ID_PAR                         int                            not null AUTO_INCREMENT,
   ID_TPAR                        int                            not null,
   NOMBRE_PAR                     varchar(50),
   primary key (ID_PAR)
);
como tendria que quedar mi SELECT para para mostrar datos propias de la tabla COMPUTADOR y las partes de mi tabla PARTE que tiene asociadas??

cluster me dijo con subconsultas en SQL o con INNERT JOIN o con LEFT/RIGTH JOIN, pero no se como hacerla
esta es mi verion mysql: MySQL 4.1.9-max

los inserte asi:
Código:
INSERT INTO computador (id_com, id_sala, id_red, ingreso_com, garantia_com, usb_com)  
VALUES ('', '$sala', '$red', '$date', '$garantia', '$usb')"; 
//INGRESO A LA TABLA COMPUTADOR SUS DATOS PROPIOS  

query="INSERT INTO usa (id_com, id_par)   
VALUES ('$id_com', '$tmadre')"; //es como decir VALUES('1', '1') 
//ASI LE EMPIEZO A ASIGNAR LAS PARTES --> PARTE NRO 1  

$query="INSERT INTO usa (id_com, id_par)   
VALUES ('$id_com', '$proce')"; //es como decir VALUES('1', '2') 
//ASI LE EMPIEZO A ASIGNAR LAS PARTES --> PARTE NRO 2, etc...

Última edición por gazuzax; 11/10/2006 a las 19:53