Skip to content

Instantly share code, notes, and snippets.

@dnasca
Created January 27, 2016 08:43
Show Gist options
  • Select an option

  • Save dnasca/96f600c4da4f8a0b3446 to your computer and use it in GitHub Desktop.

Select an option

Save dnasca/96f600c4da4f8a0b3446 to your computer and use it in GitHub Desktop.
Inner Joins - take 2 data sources and return all matching pairs of rows based on the join condition. unmatched rows are discarded
--ansi sql-92 standard syntax (filter rows in the ON clause)
SELECT
p.Name,
od.ProductId,
od.SalesOrderDetailId,
od.OrderQty
FROM
Production.Product AS p
INNER JOIN Sales.SalesOrderDetail AS od
ON p.ProductId = od.ProductId
ORDER BY
p.Name, od.SalesOrderDetailId;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment