Solved

When would _ Wildcard actually be useful?

Posted on 2013-01-29
3
195 Views
Last Modified: 2013-01-29
I am doing some tutorials and have just learnt about the _ wildcard so for example if in my table i had the first name Dario and wanted to find a name that started with any character followed by 'ario' i would use

SELECT * FROM Person WHERE FirstName LIKE '_ario'

But when would this actually be useful i am struggling to find a reason why you would want to query your database to find something that i suppose logic would help you figure out anyway?

Apologies if in the SQL world this is a stupid question still fairly new to this all!

Thanks, SuperJinx
0
Comment
Question by:SuperJinx
  • 2
3 Comments
 
LVL 4

Expert Comment

by:MimicTech
ID: 38832637
It is just a wildcard charecter that resembles a single char. I have only used it a few times, but it is nice to have.

Let's say you are storing MAC addresses in a table (ie. AA:BB:CC:11:22:33) and you want to pull all of the MAC address that have an OUI (the first 3 octets) ending in CC. For this you would have to select where MAC_ADDR like '__:__:CC:%' .

Geeky example, but you can see where combining the wildcards can give you a bit more flexability.
0
 

Author Comment

by:SuperJinx
ID: 38832652
Thanks for your answer although I have to say the example is a bit too complicated for me at the moment i can't really relate to it although i've read it 5-6 times.

None the less thank you for your answer Mimic.
0
 
LVL 4

Accepted Solution

by:
MimicTech earned 75 total points
ID: 38832886
here is a more busn related example:

let's say you were storing all employee phone numbers: and your corp's phone system was setup that all Accounting telephone were in the 4000's (ie. x4011) and all IT numbers were in the 6000's (ie. x6012). Let's also extend this to say that the office in California had telephone prefixes like 919-430-xxxx and the office in New York had prefixes like 212-679-xxxx.

if you wanted all Accounting telephone numbers in the database you could query

.... where telephone like '___-___-4___'
this would also work ... where telephone like '___-___-4%'

you could also query for all New York IT numbers like this

... where telephone like '212-679-6%'
this would also work ... where telephone like '212-679-6___'
hope this makes it a little clearer.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now