SELECT with WHERE



By:

Overview
In this example we will return a single column in our SELECT statement and add a WHERE clause to limit the records being returned.  In this circumstance all of the values from the column will be returned from the table only when the WHERE criteria is met.  Let's take a look at an example. 

Explanation
In the example below we are selecting the LoginID column from the HumanResources.Employee table where the VacationHours column equals 8.

USE AdventureWorks;
GO
SELECT LoginID
FROM HumanResources.Employee
WHERE VacationHours = 8;
GO

Below is the sample result set:


Last Update: 3/25/2009






Comments For This Article





download


get free sql tips
agree to terms


Learn more about SQL Server tools