标签:value into table blog varchar ble png 系统 img
CREATE TABLE dbo.Student ( Sno int null ,Name nvarchar(23) ) CREATE TABLE dbo.Score ( Sno int ,Score INT ) INSERT INTO dbo.Student(Sno,Name)VALUES(1,‘Jesse‘); INSERT INTO dbo.Student(Sno,Name)VALUES(2,‘Jessca‘); INSERT INTO dbo.Student(Sno,Name)VALUES(3,‘June‘); INSERT INTO dbo.Student(Sno,Name)VALUES(4,‘Supper‘); INSERT INTO dbo.Score(Sno,Score)VALUES (1,45) INSERT INTO dbo.Score(Sno,Score)VALUES (1,56) INSERT INTO dbo.Score(Sno,Score)VALUES (2,100) INSERT INTO dbo.Score(Sno,Score)VALUES (3,25)
查看数据:
SELECT * FROM dbo.Student SELECT * FROM dbo.Score
Left Join 会显示出左边的全部数据,右边如果没有对应的值,系统默认NULL
SELECT * FROM dbo.Student a LEFT JOIN dbo.Score b ON a.Sno=b.Sno
INNER JOIN 显示交集
SELECT * FROM dbo.Student a INNER JOIN dbo.Score b ON a.Sno=b.Sno
right join 右表全部显示,左表没有,默认设置为NULL
SELECT * FROM dbo.Student a RIGHT JOIN dbo.Score b ON a.Sno=b.Sno
FULL JOIN 左右边都显示,如果对方没有值得统一设置NULL
SELECT * FROM dbo.Student a FULL JOIN dbo.Score b ON a.Sno=b.Sno
SQL SERVER LEFT JOIN, INNER JOIN, RIGHT JOIN
标签:value into table blog varchar ble png 系统 img
原文地址:http://www.cnblogs.com/Jesse-Li/p/7131624.html