1. 程式人生 > >inner join 多表查詢

inner join 多表查詢

light table clas inner cnblogs sel lec select 多表

三表以及三表以上聯合查詢:

select table1.ziduan1,table2.ziduan,2,table3,ziduan3
from table1 inner join table2 
on table1.field1 = table2.field1 
inner join table3 
on table1.field1 = table3.field1

 舉例: 

select clFile.FILEPATH,clPerson.personcode,cailiao.clcode 
    from clFile inner join clPerson 
    on clFile.PGUID = clPerson.MGUID
    inner join cailiao 
    on clPerson.MGUID = cailiao.clGuid";

倆表聯合查詢:

select * FROM 
    表1 INNER JOIN 表2 
    ON 表1.字段號=表2.字段號

 舉例:

select * from CaiLiao inner 
    join clCode 
    on CaiLiao.clCode=clCode.code 
    where CaiLiao.clGUID 
    in (select mGUID from clPerson where pcode = ‘123‘ )                  

  

inner join 多表查詢