Understanding and Implementing the LIKE
Query in MySQL
MySQL offers a powerful feature called the LIKE
operator that allows you to perform pattern matching in queries. This operator is incredibly useful when you need to search for specific patterns within textual data in your database tables.
Like Query is very important syntax in sql and mysql. Like query to use different type and method for mysql Such as..
Show Company table we use to like query for this table.
SELECT * FROM `company`;
COMPANY | NAME | COUNTRY |
Arms Tech | Arvind | Lucknow |
All Techno Solution | Prveen | Uttar Pradesh |
All Jobs India | Naveen | Austria |
Working Captial | Lucky | Uk |
Data Center | Kirtisha | Canada |
Anmolgyan | Sandy | Italy |
SELECT * FROM `company` WHERE `name` like 's%'
Show OUTPUT like query Such as..
COMPANY | NAME | COUNTRY |
Anmolgyan | Sandy | Italy |
SELECT * FROM `company` WHERE `name` like '%y'
COMPANY | NAME | COUNTRY |
Anmolgyan | Sandy | Italy |
Working Captial | Lucky | UK |
Finds any values that have in any position with like query
underscore () is set position if position is third then underscore is press two times like that ( _ like __)
SELECT * FROM company where name like '__v%'
COMPANY | NAME | COUNTRY |
Arms Tech | Arvind | Lucknow |
All Techno Solution | Prveen | UTTAR PRADESH |
All Jobs India | Naveen | Austria |
SELECT * FROM `company` where company like 'a%n'
COMPANY | NAME | COUNTRY |
Anmolgyan | Sandy | Italy |
All Techno Solution | Prveen | UTTAR PRADESH |