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

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

new
Bible Basics
Houseplants
Romance Movies
Creativity
Family Travel
Southwest USA
Irish Culture


dailyclick
All times in EST

Clairvoyance: 08:00 PM

Full Schedule
g
g ASP Site

BellaOnline's ASP Editor

g

Syntax of a SQL Select Statement


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.
Add Syntax+of+a+SQL+Select+Statement to Twitter Add Syntax+of+a+SQL+Select+Statement to Facebook Add Syntax+of+a+SQL+Select+Statement to MySpace Add Syntax+of+a+SQL+Select+Statement to Del.icio.us Digg Syntax+of+a+SQL+Select+Statement Add Syntax+of+a+SQL+Select+Statement to Yahoo My Web Add Syntax+of+a+SQL+Select+Statement to Google Bookmarks Add Syntax+of+a+SQL+Select+Statement to Stumbleupon Add Syntax+of+a+SQL+Select+Statement to Reddit




RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


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


Content copyright © 2014 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 Lisa Shea for details.

g


g features
Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


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


BellaOnline Editor