MYSQLphp

how to use like query with example in mysql

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`;
COMPANYNAMECOUNTRY
Arms TechArvindLucknow
All Techno SolutionPrveenUttar Pradesh
All Jobs IndiaNaveenAustria
Working CaptialLuckyUk
Data CenterKirtishaCanada
AnmolgyanSandyItaly
SELECT * FROM `company` WHERE `name` like 's%'

Show OUTPUT like query Such as..

COMPANYNAMECOUNTRY
AnmolgyanSandyItaly
SELECT * FROM `company` WHERE `name` like '%y'
COMPANYNAMECOUNTRY
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%'
COMPANYNAMECOUNTRY
Arms Tech Arvind Lucknow
All Techno Solution Prveen UTTAR PRADESH
All Jobs India Naveen Austria
SELECT * FROM `company` where company like 'a%n' 
COMPANYNAMECOUNTRY
Anmolgyan Sandy Italy
All Techno Solution Prveen UTTAR PRADESH

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button