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.