Skip to content
  • About Author
  • About UgtWorld
  • Privacy Policy
  • The Era of Techno
  • Write With Us
Ugt world

Ugt world

Flow of Emotion

  • Artificial Intelligence Free Course
  • Google Explore
    • Career Opportunities
    • Travel and Roaming
    • Physical and Mental Health
    • Sci-Fi
  • हिंदी
    • हिंदी लेख
    • हिंदी लघु-लेख
    • हिंदी कथा
    • हिंदी कविताएँ
    • हिंदी शायरी
      • Love Shayari
      • Friendship Shayari
      • Sad-Heartbroken Shayari
      • Motivational Shayari
      • Life Shayari
      • Chai Shayari
      • Khubsurati Shayari
  • मराठी
    • मराठी लेख
    • मराठी लघु-लेख
    • मराठी लघु-लेख : २
    • मराठी कथा
    • मराठी कविता
    • मराठी चारोळ्या
      • चारोळ्या – प्रेम
      • चारोळ्या – पहाट
      • चारोळ्या – रात्र
      • चारोळ्या – आयुष्य
    • मराठी सुविचार
  • English
    • Quotes
      • Inspirational Quotes
      • Motivational Quotes
      • Life Quotes
      • Attitude Quotes
      • Love Quotes
      • Happy Quotes
      • Sad Quotes
    • Blogs
      • Social Awareness
      • Motivational
      • Life Lessons
      • Love
      • Friendship
    • Micro Blogs
    • Micro Blogs 2
    • Story
    • English Poetry
  • Banking and Finance
  • The Era of Techno
    • Social Engineering Attacks
    • Java
      • Introduction of Java, the technological language…
      • Set-up of Java
    • MySQL
    • Spring
  • Fashion Design
  • Write With Us
    • Suhani’s Write-ups
    • Revathi ‘s Write-ups
    • Rachna’s Blog
    • Pooja’s Write-ups
    • Komal’s Write-ups
    • Tanaya Talks
    • AKWrites
    • Rutuja’s Write-ups
    • Samreen ‘s Write-ups
    • शायAr
      • Marathi Blogs
      • Marathi Story
      • Hindi Blogs
      • English Blogs
      • English Stories
  • Home
  • English
  • Blogs
  • LIKE operator in MySQL
Blogs Database Era of Techno MySQL

LIKE operator in MySQL

January 6, 2023January 6, 2023 ugtworld

What is the LIKE operator in MySQL

LIKE operator in MySQL is used in the WHERE condition to get certain values of column data.

We must give the pattern in the LIKE condition to get the data. We have two signs we can use in like condition.

  1. % (percentage)
  2. _ (Underscore)

The syntax for the LIKE condition

SELECT column_name1, column_name2, …
FROM schema.table_name
WHERE column_name LIKE pattern;

We will see some examples using the above 2 signs and will see how the condition works. We will use the same ‘students’ table created in  MySQL SELECT Statement. 

  1. % using before chars
  2. % after chars
  3. % before and after chars
  4. % in between the chars
  5. _ before char and % 
  6. _ after char and %
  7. _ (to get a particular length of string values)

  1. % using before chars

Query:

select * from students where name like ‘%S’;

  • This will give the records for which name ends with S. Since we have added % before S. 
  • It will match any string that ends with S irrespective of which and how many characters are present in that string before S. 
  • We can also add multiple characters after % signs. 
  • For example, if we want to get the string ends with ‘MS’ then we can add a condition like ‘%MS’

  1. % after chars 

Query:

select * from students where name like ‘K%’;

  • This will give the records for which the name starts with K. Since we have added % after K. 
  • It will match any string that starts with K irrespective of which and how many characters are present in that string after K. 
  • We can also add multiple characters before % signs. 
  • For example, if we want to get the string starts with ‘KJ’ then we can add a condition like ‘KJ%’

  1. % before and after chars

Query:

select * from students where name like ‘%K%’;

  • This will get the records of the name which has K in it. Irrespective of the position of the K. It can be at the start, end, or in the middle.

  1. % in between the chars

Query:

select * from students where name like ‘K%Y’;

  • This will get the records of the names which start with K and ends with Y

  1. _ before char and % 

Query:

select * from students where name like ‘_K%’;

  • This will get the record for a name that has K in the second position. 
  • We can add multiple _ to define the position of the K. if we want to get the name which has K at the 3rd position we can add two underscore signs before K, like ‘__K%’;

Query: (with 2 underscores before the character)

select * from students where name like ‘__K%’; 

  1. _ after char and %

Query:

select * from students where name like ‘%K_’;

  • This will get the records for the name which has K at the second last position.

  1. _ (to get a particular length of string values)

Query:

select * from students where name like ‘_____’; 

  • Since in the above query we have added 5 underscores we will get the result for which name has 5 characters in it.

-A blog by Shwetali Khambe

Click here to read all about MySQL
0Like
0Love
0Haha
0Shocked
0Sad
0Angry

Related Posts

History of fashion part-4
Blogs Career Opportunities English Fashion Design Google Explore

History of fashion part-4

March 9, 2025March 9, 2025 ugtworld
History of fashion part-3 Indian Dynasty, The Mughal fashion
Blogs Career Opportunities English English Blogs Fashion Design

History of fashion part-3

March 7, 2025March 7, 2025 ugtworld

Post navigation

Previous: सावित्रीबाई फुले यांची सामाजिक व शैक्षणिक कार्ये
Next: The Upcoming and Involved Anime Culture in India…

Aapsi Baatchit aur Kissein / आपसी बातचीत और किस्से

Aapsi Baatchit aur Kissein / आपसी बातचीत और किस्से
Shop now on Notion Press, Amazon and Flipkart

Write With Us

Write with us

AMAZON BANNER

Follow Us

Copyright ©2024 Ugtworld. All rights reserved.
Proudly powered by WordPress | Theme: Fairy by Candid Themes.