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"
There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too. a $5 tip buys him lunch at McDonalds, a $20 tip buys his kid Hitoshi a new computer game, a $39 tip buys his daughter Michiko a few nice outfits. See our donor list.