發表文章

目前顯示的是有「開發工具類-MSSQL-淺淡JOIN」標籤的文章

自救必看三大準則

幾張圖跟你說SQL Join

圖片
引用自: 1.[SQL]Join的觀念 http://www.dotblogs.com.tw/hatelove/archive/2010/01/23/sql-join-concept.aspx?fid=69775 2.A Visual Explanation of SQL Joins http://blog.codinghorror.com/a-visual-explanation-of-sql-joins/ SELECT * FROM TableA INNER JOIN TableB ON TableA.name = TableB.name id name id name -- ---- -- ---- 1 Pirate 2 Pirate 3 Ninja 4 Ninja Inner join  produces only the set of records that match in both Table A and Table B. SELECT * FROM TableA FULL OUTER JOIN TableB ON TableA.name = TableB.name id name id name -- ---- -- ---- 1 Pirate 2 Pirate 2 Monkey null null 3 Ninja 4 Ninja 4 Spaghetti null null null null 1 Rutabaga null null 3 Darth Vader Full outer join  produces the set of all records in Table A and Table B, with matching records from both sides where available. If there is no match, the missing side will c...