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

fast-python-code
Top Five Tips to Increase the Performance of Python Code
python-program-to-find-if-a-given-number-is-odd-or-even
Python Program: To Find if a given number is Odd or Even
sql-stored-procedures
Get Started: SQL Stored Procedures – SQL Server
sql-in-operator
Get Started: SQL IN Operator
introduction-to-python-pandas-series
Introduction to Python Pandas Series
codingstreets-live-on-youtube

Top Articles

Introduction to Python Comment
Python-while-loop-Beginner-Project
Python while loop Beginner Project
TOP 10 Oldest Programming Languages That Developers Are Searching For In 2022
network-security-transposition-cipher-techniques
Network Security: Transposition Cipher Techniques
Python-Set-Beginner-Project
Python Set Beginner Project: union(), intersection(), difference(), symmetric_difference()
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