CREATE TABLE Join_teacher (
ID int primary KEY auto_increment,
T_name varchar (TEN) is not NULL,
Gender enum (' Male ', ' female ', ' secret ') not NULL
) engine InnoDB character set UTF8;
INSERT INTO join_teacher values
(1, ' Han Xin ', ' Male '),
(2, ' Li Bai ', ' Male '),
(3, ' Han Fei zi ', ' secret ');
CREATE TABLE Join_class (
ID int primary KEY auto_increment,
C_name varchar (TEN) is not NULL,
root int not nclass values
(1, ' php0115 ', 207),
(2, ' php0115 ', 207),
(3, ' php0115 ', 207);
CREATE TABLE Join_day (
ID int primary KEY auto_increment,
t_id int NOT NULL,
C_ID int NOT NULL,
Days tinyint NOT NULL,
Begin_date date NOT NULL,
End_date date NOT NULL
) engine InnoDB character set UTF8;
INSERT INTO join_day values
(1,1,1,15,20130115,20130220),
(2,2,2,20,20130222,20130325),
(3,3,3,15,20130327,20130418);
Tbl_left INNER JOIN tbl_right on join condition
INNER JOIN
Select Join_teacher.t_name,join_teacher.gender,join_day.begin_date,join_day.end_date
From Join_teacher inner join Join_day on
join_teacher.id=join_day.t_id;
SELECT * FROM Join_teacherINNER JOINJoin_day on
join_teacher.id=join_day.t_id;
Leftouter JOIN
SELECT * FROM join_teacher LEFT outer join Join_day on
join_teacher.id=join_day.t_id;
Join connection query: Connect records from multiple tables
Category: Inner connection, outer connection, natural connection
Internal connection: The connection within the data, requires that multiple connected data must exist in order to connect
Outer joins: If one or more of the data that is responsible for the connection does not exist, it is called an outer join
Select s.*,si.* from Info_class as CLeft joinInfo_student as S on c.id=s.class_id
Left joinInfo_student_info as Si on s.id=si.id where c.class_name= ' php0331 ';
Select child.* from Hd_cate as the parent left join Hd_cate as child on Child.pid=parent.id where parent.name= ' MySQL ';
Format:
SELECT * FROM table1
Left join Table2 on condition
Left join Table3 on condition
......
Add information by column ull
) engine InnoDB character set UTF8;
INSERT INTO Join_
MySQL database outside connection, internal connection, natural connection