【正文】
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 = 網絡 數據庫 技 術 及 應 用(主 講 人:潘大四) 連接查詢 Join Left Join Right Join 網絡 數據庫 技 術 及 應 用(主 講 人:潘大四) 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 這個語法是連接查詢中的內連接,它產生的結果是 兩個表相匹配的記錄出現在結果列表中。 根據上面的表,出現的結果是這樣的 StuName Cno 1 a 1 3 2 b 2 4 網絡 數據庫 技 術 及 應 用(主 講 人:潘大四) Left Join select * from tblStudent left join tblCourse on tblStudent. StuID = tblCourse. StuID 這個是外連接語法中的左外連接或右外連接 如果是左外連接的話,它將顯示 tblStudent表的所有記錄, 查詢的結果是這樣的: StuName Cno 1 a 1 3 2 b 2 4 3 c null null 網絡 數據庫 技 術 及 應 用(主 講 人:潘大四) Right Join 如果是右外連接的話,它將顯示 tblCourse表的所有記錄, select * from tblStudent right join tblCourse on tblStudent. StuID = tblCourse. StuID 查詢的結果是這樣的: StuName Cno 1 a 1 3 2 b 2 4