【正文】
e translated into FROMclause joins by SQL Server). ? While the JOIN condition notation is the preferred method of creating join queries, the oldstyle WHERE notation is still used in certain circumstances, such as subqueries. Whenever possible, use the JOIN condition notation over the WHERE notation, but at the same time, be aware that the older style is still used. SELECT , FROM tblProduct inner JOIN tblCategory ON = 網(wǎng)絡(luò) 數(shù)據(jù)庫 技 術(shù) 及 應(yīng) 用(主 講 人:潘大四) 連接查詢 Join Left Join Right Join 網(wǎng)絡(luò) 數(shù)據(jù)庫 技 術(shù) 及 應(yīng) 用(主 講 人:潘大四) Inner Join StuID StuName 1 a 2 b 3 c StuID Cno 1 3 2 4 tblStudent tblCourse select * from tblStudent inner join tblCourse on tblStudent. StuID = tblCourse. StuID 這個(gè)語法是連接查詢中的內(nèi)連接,它產(chǎn)生的結(jié)果是 兩個(gè)表相匹配的記錄出現(xiàn)在結(jié)果列表中。 根據(jù)上面的表,出現(xiàn)的結(jié)果是這樣的 StuName Cno 1 a 1 3 2 b 2 4 網(wǎng)絡(luò) 數(shù)據(jù)庫 技 術(shù) 及 應(yīng) 用(主 講 人:潘大四) Left Join select * from tblStudent left join tblCourse on tblStudent. StuID = tblCourse. StuID 這個(gè)是外連接語法中的左外連接或右外連接 如果是左外連接的話,它將顯示 tblStudent表的所有記錄, 查詢的結(jié)果是這樣的: StuName Cno 1 a 1 3 2 b 2 4 3 c null null 網(wǎng)絡(luò) 數(shù)據(jù)庫 技 術(shù) 及 應(yīng) 用(主 講 人:潘大四) Right Join 如果是右外連接的話,它將顯示 tblCourse表的所有記錄, select * from tblStudent right join tblCourse on tblStudent. StuID = tblCourse. StuID 查詢的結(jié)果是這樣的: StuName Cno 1 a 1 3 2 b 2 4