SQL查询,关联查询的区别 (LEFT JOIN 、LEFT OUTER JOIN、INNER JOIN)

 CREATE TABLE #a(f1 VARCHAR(30),    f2 VARCHAR(40) )
CREATE TABLE #b(f1 VARCHAR(30), f2 VARCHAR(40) )
------------------------------------------------
INSERT INTO #a(f1,f2)VALUES('','a1')
INSERT INTO #a(f1,f2)VALUES('','a2')
INSERT INTO #a(f1,f2)VALUES('','a3')
INSERT INTO #a(f1,f2)VALUES('','a4')
-------------------------------------
INSERT INTO #b(f1,f2)VaLUES('','b1')
INSERT INTO #b(f1,f2)VaLUES('','b2')
--INSERT INTO #b(f1,f2)VALUES('3','b3')
--INSERT INTO #b(f1,f2)VaLUES('4','b4')
SELECT a.*,b.*
FROM #a AS a LEFT JOIN #b AS b ON a.f1 = b.f1
--
SELECT a.*,b.*
FROM #a AS a LEFT OUTER JOIN #b AS b ON a.f1 = b.f1
-----------
SELECT a.*,b.*
FROM #a AS a , #b AS b WHERE a.f1 = b.f1
--
SELECT a.*,b.*
FROM #a AS a INNER JOIN #b AS b ON a.f1 = b.f1

SQL查询,关联查询的区别 (LEFT JOIN 、LEFT OUTER JOIN、INNER JOIN)

上一篇:POJ 2970 The lazy programmer


下一篇:kvm虚拟机安装