CHAPTER 4

image

Querying from Multiple Tables

by Jonathan Gennick

It is the rare database that has all its data in a single table. Data tends to be spread over multiple tables in ways that optimize storage and ensure consistency and integrity. Part of your job when writing a query is to deploy and link together T-SQL operations that can operate across tables in order to generate needed business results.

Building blocks at your disposal include:

  • Joins. Imagine holding two spreadsheets side by side. A join takes two rowsets and combines the rows from each to create a single rowset having the combined columns. Look towards a join when you want to correlate ...

Get SQL Server 2012 T-SQL Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.