Home
Username:
Password:
Adobe ColdFusion 8 Tutorials

Basic SQL Statements / SQL Wildcard




Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com’s entire library of video tutorials.


Learn More

Subtitles of the Movie

What we're going to take a look at now are the SQL Wildcards and also the LIKE Operator and these are SQL-specific. Every database will honor these and they allow you to create searches based on particular patterns in a word inside of the database; you don't have to match something up specifically, so I'll show you what I'm talking about. Here's a basic example, so you just list the column names in your SELECT and the table name, just like you normally would. Down here in your WHERE Statement and these double quotes do not actually get used - I'll show you an example down below - it's just representing a specific column name and matching it up to a particular pattern. So, the pattern can consist of Wildcards and one of the Wildcards is an underscore. The underscore represents exactly one character. So if I searched for C underscore 1 then I would get a C then a single character and then the number 1 in my search. The Wildcard, percentage sign, is actually used more often and what that does is stands for any number of characters, so if you did a match for C percentage sign, what it would do is pull out all of the items that start with the letter C and then have one or more characters after them. So, here's an example in our code, so we're going to SELECT EmployeeID, LastName, FirstName and Department from our Employees table. What we want to pull out are all of the employees whose first two letters in their last name, in other words in the lastName column in our Employees table, we're going to pull out all employees whose last name start with a capital M and an a. So, we have an Ma, that would be my last name, so my name would be pulled out along with whoever else has a last name that begins with an M and an a. That gives you a little taste for the Wildcard. Now I could also do it this way. I could put a percent lowercase m. What that would do is pull out all of the last names in the Employees table who have an m and an a in them and characters on either side. So there are some resources on my cmairscreate.com website in the SQL area to discuss Wildcards and give you a few more examples. We will also be creating a Search Form for our website and actually working with this percentage character there when we're building our queries in ColdFusion. So that is SQL Wildcards and the LIKE Operator.

Tutorial Information

Course: Adobe ColdFusion 8
Author: Candyce Mairs
SKU: 34093
ISBN: 1-936334-05-4
Release Date: 2010-02-26
Duration: 8 hrs / 112 lessons
Work Files: Yes
Captions: Available on CD and Online University
Compatibility: Vista/XP/2000, OS X, Linux
QuickTime 7, Flash 8

VTC Sign up & Benefits

  • Unlimited Access
  • 98,729 Video Tutorials (23,265 free)
  • Video Available as Flash or QuickTime
  • Over 1026 Courses
  • $30 for One Month Access
  • Multi-User Discounts Available