ASP Is Fun

Learning ASP
Free Course
Basics
Functions
SQL Commands
Sample Code


Servers / Setup
Host Reviews
Server Setup
Error Tips


Contract ASP
Development

Search For:


Intro to ASP


 


Like Statement in SQL - Inexact Wildcard Matches



If you're writing a SQL statement, sometimes you want wildcarded matches. The LIKE command lets you get matches that are similar to a phrase you supply.

Normally, if you write a SQL statement, you're looking for an exact match. If you're looking for all books written by SMITH, you would write:

SELECT * from books where author_name = 'SMITH';

and only those rows would be returned. What, though, if you are doing a search and want everything CONTAINING that word? What, for example, if you have a person put the word HORSE into your search box and want to return every title in your library containing the word HORSE? In that case you would write

SELECT * from books where book_title LIKE '%HORSE%';

The % is the wildcard symbol in SQL. If you wanted everything that began with HORSE, you would say

SELECT * from books where book_title LIKE 'HORSE%';

but usually you want the % on both sides of the word, so that if the HORSE shows up ANYWHERE in the title, you get the results.

SQL Command Listing

Bookmark this site so you can reference it any time you have ASP questions in the future!




ASP Main Page | ASP Ebooks | Free ASP Course | Contact Lisa
All content copyright © 2012 Minerva WebWorks LLC. All rights reserved.

Irish Wedding


Free Newsletter!

Ebooks
Intro to ASP
ASP SQL DB
Members
Shopping


Introduction to ASP

Romance Tips
Irish Romance
Italian Romance
French Romance

ASP Poll
How do you handle 500 errors?
I don't
Page does nothing
Displays error
Emails error