Skip to content
Facebook-f Instagram Youtube Pinterest
codingstreets
  • HOME
  • INSIGHTS
    • BLOG
    • ARTICLES
  • TUTORIALS
    • PYTHON
      • PYTHON MODULES
        • NUMPY
        • PANDAS
        • SCIPY
    • MATPLOTLIB
    • MACHINE LEARNING
      • ML + AI THEORY
    • PYTHON MYSQL
    • SQL
      • SQL DATABASE
      • SQL THEORY
    • JAVA
      • JAVA THEORY
  • PROJECT
    • PYTHON PROJECT
  • ABOUT
  • CONTACT US
  • HOME
  • INSIGHTS
    • BLOG
    • ARTICLES
  • TUTORIALS
    • PYTHON
      • PYTHON MODULES
        • NUMPY
        • PANDAS
        • SCIPY
    • MATPLOTLIB
    • MACHINE LEARNING
      • ML + AI THEORY
    • PYTHON MYSQL
    • SQL
      • SQL DATABASE
      • SQL THEORY
    • JAVA
      • JAVA THEORY
  • PROJECT
    • PYTHON PROJECT
  • ABOUT
  • CONTACT US
sql-like-operator

Get Started: SQL LIKE Operator

  • March 29, 2022
In This Article, You Will Know About SQL LIKE Operator. 

SQL Functions – Before moving ahead, let’s know a bit about SQL MIN() and MAX() Functions.

Table of Contents

SQL LIKE operator

The SQL LIKE operator is used with the WHERE clause to find out the specified pattern in the column.

Two most popular wildcards are used with the LIKE operator:

(%) – The percentage (%) sign is used to match zero, one, or multiple characters.

(_) – The underscore sign is used to represent one or a single character.

Syntax

				
					SELECT column1, column2, ...
FROM table_name
WHERE column LIKE pattern;
				
			

Here are some examples showing different LIKE operators with ‘%’ and ‘_’ wildcards:

LIKE Operator

Description

WHERE CustomerName LIKE ‘A%’

Finds any values that start with “A”

WHERE CustomerName LIKE ‘%x’

Finds any values that end with “x”

WHERE CustomerName LIKE ‘%e%’

Finds any values that have “e” in any position

WHERE CustomerName LIKE ‘_l%

Finds any values that have “_l” in the second position

WHERE CustomerName LIKE ‘R____%’     

Finds any values that start with “R” and are at least 5 characters in length

WHERE ContactName LIKE ‘A%x’

Finds any values that start with “A” and ends with “x”

Example Database

Below is the example of a database table named “details.”

Id

Name

Class

section_id

1

Alex

5

1

2

Rolex

6

2

3

Salex

7

2

4

Lelex

8

3

5

Kelex

9

5

SQL LIKE Examples

Example: Use LIKE operator to return the match starts with ‘A’.

				
					SELECT * FROM details
WHERE Name LIKE 'A%';
				
			

As a result, it returns the all names starts with “A” from the whole table.

Example: Use LIKE operator to return the match starts with ‘S’.

				
					SELECT Name 
FROM details
WHERE Name LIKE 'S%';
				
			

As a result, it returns the all names starts with “S” from the “Name” column.

Example: Use LIKE operator to return the match ends with ‘x’.

				
					SELECT Name 
FROM details
WHERE Name LIKE '%x';
				
			

As a result, it returns the all names ends with “x” from the “Name” column.

Example: Use LIKE operator to return the match have ‘e’ character at any position.

				
					SELECT Name 
FROM details
WHERE Name LIKE '%e%';
				
			

As a result, it returns the all names that contains “e” at any position from the “Name” column.

Example: Use LIKE operator to return the match have ‘l’ character in the second position.

				
					SELECT * FROM details
WHERE Name LIKE '_l%';
				
			

As a result, it returns the all names that contains second character “l” from the whole table.

Example: Use LIKE operator to return the match have ‘R’ character in the first position.

				
					SELECT * FROM details
WHERE Name LIKE 'R____%';
				
			

As a result, it returns the all names from the whole table that starts with character “R” and have at least total 5 characters in the length.

Example: Use LIKE operator to return the match have ‘R’ character in the first position, ‘l’ at any position, and ‘x’ at the last position.

				
					SELECT * FROM details
WHERE Name LIKE 'R__l__x%';
				
			

As a result, it returns the all names from the whole table that starts with character “R” and have at least total 5 characters in the length.

Example: Use LIKE operator to return the match have ‘A%x’ character “A” in the starting and “x” at the last.

				
					SELECT * FROM details
WHERE Name LIKE 'A%x';
				
			

As a result, it returns the all names from the whole table that starts with character “A” and end with character “x”.

If you find anything incorrect in the above-discussed topic and have further questions, please comment below.

Connect on:

Facebook Instagram Twitter Pinterest
PrevPreviousSQL Functions : COUNT(), AVG() and SUM()
NextGet Started: SQL WildcardNext

Recent Post

Sora-ChatGPT-Image-Tutorial
Sora ChatGPT Image Tutorial: How to create AI Images using ChatGPT Sora AI Model
ChatGPT-Ghibli-Tutorial
ChatGPT Ghibli Tutorial: How to create Studio Ghibli Style Portraits
Python-Bulk-Email-Sender
Python Bulk Email Sender Using Gmail & Google Sheets
Python-Bulk-Email-Automation
Python Bulk Email Automation using Gmail
Python-Chatbot-for-Beginners
How to Create a Python Chatbot for Beginners

Popular Post

Programming Languages That Will Rule In 2022
introduction-to-jdk-jre-and-jvm
Introduction to JDK, JRE, and JVM
person coding on laptop
Software Engineering: An Introduction to Software Development
Get Started: SQL WHERE Clause
numpy-rounding-decimals
Introduction to Numpy Rounding Decimals in Python
codingstreets-live-on-youtube

Top Articles

best-python-ides-for-developers-in-2023
Best Python IDEs For Developers in 2023
blue background with text overlay
Python Program: Find Palindrome Number in Python
dsa-introduction-to-tower-of-hanoi
DSA: Introduction to Tower of Hanoi
robot hands meet to human hand
Artificial Intelligence – Introduction to AI Models
introduction-to-evaluation-of-infix-postfix-expression
Introduction to Evaluation of Infix/Postfix Expression
Archives
Categories
Tags
2023 Article Articles Articles 2021 codingstreets java java language java language 2022 java theory Machine Learning Network Security Network Security 2023 python python article python article 2022 Python Articles Python Articles 2022 Python Beginner Project python introduction python language python matplotlib python matplotlib tutorial 2021 Python MySQL Python mysql 2022 python numpy python numpy array Python Numpy Tutorial python numpy tutorial 2021 python numpy tutorial august 2021 python numpy tutorial sept 2021 python pandas concept Oct 2021 python pandas tutorial Sept 2021 python program python programming language article 2022 Python Project Python SQL Python SQL 2022 python string Python String Method Python String Method 2021 Python String Method tutorial 2022 SQL Theory start with python string concept string introduction

Share on

Subscribe to our newsletter

Just a step behind to get all updates
Don’t miss new updates on your mail


Loading

Useful Links

  • FEEDBACK
  • SITEMAP
  • HELP

Get Started

  • TUTORIALS
  • PROJECTS
  • ARTICLES

About

  • TERM & CONDITIONS
  • PRIVACY & POLICY
  • DISCLAIMER
Facebook Instagram Youtube Pinterest

Copyright © 2025 codingstreets.com - All Rights Reserved