Learn more about SQL Server tools

mssqltips logo
 

Tutorials          DBA          Dev          BI          Career          Categories          Webcasts          Scripts          Today's Tip          Join

Tutorials      DBA      Dev      BI      Categories      Webcasts

DBA    Dev    BI    Categories

 

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




More SQL Server Solutions











Post a comment or let the author know this tip helped.

All comments are reviewed, so stay on subject or we may delete your comment. Note: your email address is not published. Required fields are marked with an asterisk (*).

*Name    *Email    Email me updates 


Signup for our newsletter
 I agree by submitting my data to receive communications, account updates and/or special offers about SQL Server from MSSQLTips and/or its Sponsors. I have read the privacy statement and understand I may unsubscribe at any time.



    



Learn more about SQL Server tools