Link to home
Start Free TrialLog in
Avatar of SuperJinx
SuperJinx

asked on

When would _ Wildcard actually be useful?

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
Avatar of MimicTech
MimicTech

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.
Avatar of SuperJinx

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of MimicTech
MimicTech

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial