Qondio
Front
Intel
IntelMart
Shares
My Qondio
Account
dspohn23 > Intel > TSQL SELECT Tutorial

qondio.com/ahsu PRINT EMAIL

TSQL SELECT Tutorial

Introduction

The SELECT statement is used for retrieving data from a table. This SQL Statement begins with the keyword SELECT. The results from the SELECT query is called the 'Result set'. The SELECT Statement has two basic parts:

* SELECT
* FROM

following the 'SELECT' keyword will be the columns to be selected
following the 'FROM' keyword will be the table to be selected from.

Beginning Example

This example will select the 'Name', 'Position' and 'Salary' columns' content from the 'Employees' table. Note: This example selects all of the records from the table.


SELECT Name, Position, Salary
FROM Employees Here is a sample result set from the above SELECT query:


Name Position Salary
Joe Grape Manager 80000
John Plum Software Developer 65000
Frank Apple Software Developer 62000
Patty Pineapple Software Developer 60000
Judy Peach Software Developer 50000
Jane Orange Project Manager 75000

Selecting ALL Columns - *

Previously we selected columns by specifying the column names. By using the * symbol, we can select all the columns from a table

In this example we will assume that the 'Employees' table contains the follow columns: 'Name', 'Position', 'Office' and 'Salary'.


SELECT *
FROM Employees

Here is a sample resultset from the above SELECT query:


Name Position Office Salary
Joe Grape Manager Houston 80000
John Plum Software Developer Houston 65000
Frank Apple Software Developer Cleveland 62000
Patty Pineapple Software Developer Cleveland 60000
Judy Peach Software Developer Boston 50000
Jane Orange Project Manager Houston 75000

Limiting Rows - WHERE clause

The WHERE clause acts as a filter on the result set. By adding a WHERE clause after the FROM keyword, the result set can be limited to rows that meet particular conditions.

This example will select the 'Name', 'Position' and 'Salary' columns' content from the 'Employees' table, where the employee's Position is 'Manager'.


SELECT Name, Position, Salary
FROM Employees
WHERE Position = 'Manager'

Here is a sample result set from the above SELECT query:


Name Position Salary
Joe Grape Manager 80000

This example will select the 'Name', 'Position' and 'Salary' columns' content from the 'Employees' table, where the employee's Salary is greater than 61,000.


SELECT Name, Position, Salary
FROM Employees
WHERE Salary > 61000

Here is a sample result set from the above SELECT query:


Name Position Salary
Joe Grape Manager 80000
John Plum Software Developer 65000
Frank Apple Software Developer 62000
Jane Orange Project Manager 75000

Read full post here: TSQL SELECT Tutorial

Contributed by dspohn23 on September 14, 2008, at 11:44 AM UTC.

PLEASE VISIT THE CONTRIBUTOR'S WEBSITE
TSQL Tutorials
Tutorials for Microsoft's TSQL
www.tsqltutorials.com

Reactions

No reactions yet.

Rate This Intel

Please login or sign up to rate this intel.

Comments

Please login or sign up to add a comment.

Share

Copyright Notice

The copyright for this content entitled "TSQL SELECT Tutorial" has been specified by the contributor as:

All Rights Reserved

This content may not be copied, distributed or adapted by anyone under any circumstances.

Login Here with
Any Email Address
Any Password
No account? Sign up.

Intel Contributor
This intel was contributed by dspohn23

Qondio Archive
May, 2012
123456
78910111213
14151617181920
21222324252627
28293031


2008
January, February, March, April, May, June, July, August, September, October, November, December
2009
January, February, March, April, May, June, July, August, September, October, November, December
2010
January, February, March, April, May, June, July, August, September, October, November, December
2011
January, February, March, April, May, June, July, August, September, October, November, December
2012
January, February, March, April, May

Sign Up
Not a member yet? Qondio is a powerful network for making it online. If you have a website to promote, we can help. Sign up and get in on the action.

About Qondio
Welcome to Qondio! Discover the awesome power this network can deliver by going to our About page. Or you could skip straight to the Sign Up form.

ABOUT
SUCCESS GUIDE
FEATURES
FAQ
ADVERTISE
CONTACT
USAGE POLICY
PRIVACY POLICY


TWITTER
FACEBOOK