Solved

When would _ Wildcard actually be useful?

Posted on 2013-01-29
3
199 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard 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 we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 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