Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  SQL: Example Tables
     [next Lesson]   SQL: Where Clause Examples

Search Database #1 (SQL Where clauses)

There are several ways to search the data using pure SQL once we review the simple rules of how a WHERE clause works.

  • Text fields must be enclosed in single quotes, i.e.
    "select * from publishers where state='MD'
  • Numeric fields need no special characters before and after
    "select * from publishers where PubID=10"
  • If you aren't sure how to spell the text field or are looking for sound alikes, LIKE supports %% wildcards
    "select * from publishers where Name like 'A%%'"

These basic WHERE clause guidelines above are the fundamental building block of searches.

It is also helpful to utilize the equality operators, i.e.

<> not equal
> greater than
< less than
>= greater than OR equal
<= less than or equal
  • Numeric fields benefit most from the equality operators:
    "select * from publishers where PubID>10"
Chaz Wish List
Tall Tip $5
Grande Tip $20
Venti Tip $39
Tip Jar Thanks
2004 Thanks
2005 Thanks
HUGE Tip -love site