Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Applications of "is like" in select expert?

Status
Not open for further replies.

arachnoid

Programmer
Jun 14, 2002
108
US
I understand that the "?" represent one character and the "*" is basically a wildcard, but could someone give some examples of practical applications of this function?

Thanks
 
Arachnoid,

The wildcards are useful for when you can only identify a record set with a partial string.

For example:

If you have the following records in your db:

Customer ID Customer Name
----------- -------------
1 Smith
2 Smyth
3 Jones
4 Bobajob

You could fetch the first two records by using a clause in your selection criteria to return the first two records:

Customer Name like 'Sm*'

which would return the first two records. The question mark would also work in this case, as both names have only one character difference between them. i.e.

Customer Name like 'Sm?th'

would return the same thing.

The thing to bear in mind with the like function is that it's useful to return bunches of rows where only part of a field matches what you are looking for, but if you are querying a database, anything which has an asterisk or question mark in it will not use any indexes, so you may get some performance slow down.

Naith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top