Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

When would _ Wildcard actually be useful?

Posted on 2013-01-29
3
Medium Priority
?
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 225 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
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.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

636 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