tabla auto referenciada

preview_player
Показать описание
create database tutoriales;

use tutoriales;

create table usuarios
(
id int auto_increment primary key,
nombre1 varchar(50) not null,
nombre2 varchar(50) ,
apellido1 varchar(50) not null,
apellido2 varchar(50) ,
fecha_nacimiento date ,
fk_pariente int
);

insert into usuarios ( id,nombre1 ,nombre2 ,apellido1 ,apellido2 ,fecha_nacimiento,fk_pariente )
values
(1,"Rodolfo","","Gonzales","Borbon","1972-09-06",null),
(2,"Florentino","","Gonzales","Camoranessi","1976-01-19",null),
(3,"Anastasio","","Gonzales","Nissen","1971-02-12",null),

(4,"Andres","Esteban","Lopez","Ramirez","1992-03-29",1),
(5,"Cristian","Camilo","Gonzales","Estrada","1992-06-09",1),
(6,"Daniel","Mariano","Soto","Cortes","1992-06-19",null),
(7,"Juan","Andres","Castro","Isaza","1992-06-19",null),
(8,"Antonio","Julian","Castro","Robayo","1992-07-01",null),
(9,"Jhony","Andres","Gonzales","Cristancho","1994-07-01",2),
(10,"Javier","Mariano","Gonzales","Estrada","1995-05-10",null),
(11,"Raul","Omar","Gonzales","Cristancho","1991-07-01",2),
(12,"Octavio","Eliseo","Gonzales","Cristancho","1993-07-01",null),
(13,"Francisco","Sebastian","Gonzales","Cristancho","1992-07-01",3),
(14,"Jhony","Andres","Gonzales","Cristancho","1990-07-01",1),

(15,"Cristian","Camilo","Gonzales","Romero","2012-09-06",11),
(16,"Daniel","Emiliano","Gonzales","Solorzano","2012-01-19",4),
(17,"Juan","Omar","Gonzales","Nissen","2011-02-12",5),
(18,"Esteban","Julian","Gonzales","Hurtado","2012-07-10",13),
(19,"William","Andres","Gonzales","Melero","2012-04-01",14)

select * from usuarios;

left join en mysq, el concepto aplica para cualquier gestor de bases de datos relacionales. uso del left join en mysql,
el concepto aplica para cualquier gestor de bases de datos relacionales....
Рекомендации по теме