关于sql server数据库??在线急等

来源:百度知道 编辑:UC知道 时间:2024/05/30 22:46:09
有高手能帮我教下sql server 中的内联和外联吗??我不懂?首先用个简单的例子说明什么多表查询内联和外联.以及它们的区别。还有它们怎么用,用个例子说明下,还有where,join...on..怎么用。我是自学,我的书太垃级写的很少而且很不清楚。希望高手指南,过后加分谢谢啦。

内连接: select * from table1 inner join table2 on table1.id = table2.id

select * from table1 , table2 where table1.id = table2.id

内联 两个表是绝对的条件连接, 会过滤其他不符合连接条件数据

外链接:select * from table1 left join table2 on table1.id = table2.id
等效(select * from table1 inner join table2 on table1.id *= table2.id)

外联1 一个表条件关联另一个表的数据, 如上table1表不符合连接条件的数据不会过滤掉,只是table2表无对应数据,相应列补NULL

select * from table1 right join table2 on table1.id = table2.id
等效(select * from table1 inner join table2 on table2.id *= table1.id)

外联2 如外联1 只是table1 table2 表角色变化了,自己理解一下

内连接: select * from table1 inner join table2 on table1.id = table2.id

select * from table1 , table2 where table1.id = table2.id

外链接:select * from table1 left join table2 on table1.id = table2.id
select * from table1 right join table2 on table1.id = table2.id