Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi
Is it possible to create a parameter to select multiple criteria, by using "Like" for retrieving data begininning with A, eg A* ??
Ta
Kasey

Hi Kasey,
This response might be a little late, but for the sake of this unanswered question, here goes:
Yes, you can use the wildcards to select specific data.
Using the LIKE condition, you can use two wildcards:
% allows you to match a string of any length
_ allows you to match a single characterex.1
SELECT * FROM users WHERE lastname LIKE 'A%'This would find all of the records in the users table with the lastname beginning with the letter A.
ex.2
SELECT * FROM users WHERE lastname LIKE '%son%'This would find records where the lastname contains the letters 'son':
Johnson
Bissonnett
Simpsonex.3
SELECT * FROM users WHERE firstname LIKE 'C_nd_'Using the _ wildcard finds all firstname possibilities:
Candi
Candy
Cindi
Cindy
Condiex.4
SELECT * FROM users WHERE lastname NOT LIKE 'A%'Returns all records EXCEPT for lastnames which begin with the letter 'A'
ex.5
SELECT * FROM users WHERE lastname LIKE 'A%' ORDER BY id ASCReturns all lastnames beginning with letter 'A' and organizes them in ascending order (ASC) according to the unique id index, and aren't in alphabetical order.
ex.6
SELECT * FROM users WHERE lastname LIKE 'A%' ORDER BY lastname ASCAgain, returns all lastnames beginning with the letter 'A', yet they are organized in ascending order according to the lastname. This has the effect of alphabetizing them.
Using DESC would reverse the order, be it alpha or numeric, depending on the field you are using with the ORDER BY clause.

One last thing:
The LIKE condition can be used in all SQL statements - SELECT, INSERT, UPDATE, DELETE

![]() |
cpp builder
|
Excel programming
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |