首页 > 代码库 > SQL 联合查询

SQL 联合查询

http://www.3lian.com/edu/2013/05-14/69869.html

 

内联inner join (类似交集)、左联left outer join 、右联right outer join 、全联full outer join(类似并集)。

 

内联:(类似交集)

select * from T1 ,T3 where T1.userid = T3.userid(其实这样的结果等同于select * from T1 inner join T3 on T1.userid=T3.userid 

 

SELECT S_USER.USERNAME, S_OFFICE.FULLNAME FROM S_USER, S_OFFICE WHERE S_USER.OFFICEID = S_OFFICE.OFID;

相当于

SELECT S_USER.USERNAME, S_OFFICE.FULLNAME FROM S_USER INNER JOIN S_OFFICE ON S_USER.OFFICEID = S_OFFICE.OFID;

SQL 联合查询