官术网_书友最值得收藏!

  • Learn T-SQL Querying
  • Pedro Lopes Pam Lahoud
  • 171字
  • 2021-06-24 14:38:09

INNER JOIN

Inner joins compare the rows from two tables based on conditions specified in the query. Typically, this type of join would be used to intersect rows that have the same value in a specific column or set of columns. The only rows that would be returned are the ones that have matching rows in both tables, as represented in black in the following diagram:

For example, the AdventureWorks sample database has a Product table that contains the ProductID and Name columns and a ProductInventory table that contains the ProductID and Quantity columns. To write a query that returns the product name and the quantity together, an inner join can be used to combine rows from the Product table with rows from the ProductInventory table based on matching values in the ProductID column. In this case, only products that have rows in both tables will be returned. The query would look like the following:

SELECT Name AS ProductName, Quantity
FROM Production.Product
INNER JOIN Production.ProductInventory ON Product.ProductID = ProductInventory.ProductID;
主站蜘蛛池模板: 泰顺县| 江川县| 迁西县| 贡觉县| 疏勒县| 涞源县| 宾川县| 商河县| 仁寿县| 苏州市| 阿克陶县| 南川市| 青龙| 建德市| 南溪县| 双江| 巩义市| 雷波县| 罗田县| 鸡泽县| 郸城县| 应用必备| 年辖:市辖区| 湖北省| 宝坻区| 枣阳市| 永顺县| 万山特区| 兴和县| 磴口县| 清徐县| 江都市| 泗洪县| 盖州市| 巧家县| 博乐市| 华亭县| 高雄市| 库尔勒市| 墨玉县| 湖南省|