mysql-- multi-table - inner join query

The join queries: query may be two or more tables, when the two tables have the same meaning as the field represented, the two tables may be connected through this field;

                      When the value of the field, to check out the recording.

 

Preparation of two tables:

create table employee ( num int(50),
                        d_id int(50),
                        name varchar(50),
                        age int(50),
                        sex varchar(50),
                        homeadd varchar(50)
                       );

insert into employee values(1,1001,'zhangsan ' , 26 is , ' NaN3 ' , ' Beijing ' ); INSERT INTO Employee values ( 2 , 1001 , ' Lisi ' , 24 , ' NV ' , ' hunan ' ); INSERT INTO Employee values ( . 3 , 1002 , ' wangwu ' , 25 , ' NaN3 ' ,'jiangsu'); insert into employee values(4,1004,'aric',15,'nan','yingguo');

select * from employee;



create table department ( d_id int(50), d_name varchar(50), functione varchar(50), address varchar(50) );
insert into department values(1001,'keyanbu','yanfachanpin','3lou5hao'); insert into department values(1002,'shengchanbu','shengchanchanp','5louyiceng'); insert into department values(1003,'xiaoshoubu','cehuaxiaoshou','1louxiaoshoudating');

select * from department;

 

 

 

 

 

 

Execute the query:

select num,name,employee.d_id,age,sex,d_name,functione from employee,department where employee.d_id = department.d_id;

Guess you like

Origin www.cnblogs.com/xiaobaibailongma/p/12093023.html