logo
g Text Version
Auto
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Society & Culture
Sports
Travel & Leisure
TV & Movies

dailyclick
Bored? Games!
Postcards
Astrology
Take a Quiz
Rate My Photo

new
Women's Issues
Teaching LDS
Relationships
Action Movies
Twins


dailyclick
All times in EST

Full Schedule
g
g ASP Site
Editor Wanted
BellaOnline's ASP Editor

g

Syntax of a SQL Select Statement
Guest Author - Lisa Shea

The most common thing to do with ASP is show information stored in a database. Here are the basics of the SQL Select statement, to get that information.

SELECT field1, field2 FROM tablename WHERE condition

So that is the basic syntax. Say you had a table called WRITERS and you wanted to select the fields called first_name and last_name. You would use

SELECT first_name, last_name FROM writers

Now say you wanted to only get the writers whose last name was SMITH. You would use

SELECT first_name, last_name FROM writers WHERE last_name = 'SMITH'

You can do multiple conditions using AND and OR if you want. Let's say you only want the writers whose first name is JULIE and last name is SMITH. You would use

SELECT first_name, last_name FROM writers WHERE first_name = 'JULIE' and last_name = 'SMITH'

You can use > and < on fields that are numeric. Let's say the writers table has another field called hourly_rate that is a number. You can select all writers that charge less than $100 an hour with this select statement -

SELECT first_name, last_name FROM writers WHERE hourly_rate < 100

You can use wildcards on STRING FIELDS ONLY - not on text fields. The wildcard symbol is a % and you have to use it in conjunction with the keyword LIKE. So to find all writers whose last names begin with the letter S, you would say:

SELECT first_name, last_name FROM writers WHERE last_name LIKE 'S%'

For more about ASP and Select, read the following two articles.

Handling Apostrophes in ASP and SQL
Using ASP to Select from a Database

Introduction to ASP Ebook

Download this ebook to get everything you need to know about learning ASP - from a step by step tutorial to function lists, sample code, common errors and solutions, and much more! 101 pages.

This site needs an editor - click to learn more!

RSS | Related Articles | Previous Features | Site Map


Content copyright © 2008 by Lisa Shea. All rights reserved.
This content was written by Lisa Shea. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.

Digg! g delicious Save to Del.icio.us

g


For FREE email updates, subscribe to the ASP Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor

g features
Best uses for RSS

RSS and its future.

Force Download Dialog box with ASP

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Driving Amount
Much more
Slightly more
Slightly less
Much less

g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2008 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor