Are you ready uncovering the power of SQL matching patterns?
In the realm of database querying, grasping the matching pattern will make our query more accurate. It's akin to having a finely tuned radar, enabling us to pinpoint exactly what we're looking for amidst vast seas of data.
In this blog you will learn how to use LIKE, ILIKE, and NOT LIKE. By understanding this this matching pattern we can transform our queries for searching into more precise tools, and more accurate extraction of what data we want to fetch.
Without further ado lets start now the familarization on this pattern.
Understanding LIKE and ILIKE: What Sets Them Apart?
At first glance, **LIKE **and **ILIKE **may seem interchangeable, both serving the purpose of pattern matching within SQL queries. However, a subtle yet significant distinction exists between these two operators.
LIKE : This matching pattern allow us to search within text data. It operates on a case-sensitive basis. meaning it distinguishes between uppercase and lowerchase characters. for example in query
SELECT * FROM Product WHERE name LIKE '%APPLE%';
The output will be all the name with APPLE word on it. its case sensitive so it will only select all the name where the APPLE is capital not included the small one.
ILIKE : This matching pattern allow us to search also within text data. but this one is case-insensitive This operator performs pattern matching without regard to case sensitivity, making it a versatile tool for scenarios where we want our search to encompass all possible variations of letter casing. for example in query
SELECT * FROM Product WHERE name ILIKE '%apple%'
The output will be all the name with apple word on it. with ILIKE would match not only 'apple' but also 'Apple' and 'APPLE.
By understanding this subtle difference, we can wield LIKE and ILIKE with precision, So let's take advantage of this of how we gonna use it.
The next is NOT LIKE which is the inverse of LIKE and ILIKE that excluding the rows that match the specified pattern. for example in query
SELECT * FROM product WHERE name NOT LIKE '%apple%'
It will exclude all the name with apple word on it. this is case-sensitive meaning it will only remove the 'apple' but not the 'Apple' and 'APPLE' word on it.
Very basic right? now that you know the LIKE, ILIKE and NOT LIKE matching pattern why not using it in your matching pattern query? to make your extracting data more precision than before?
That's it, and thanks for reading if you've made it this far!
Top comments (0)