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

Python-Mutable-Default-Arguments
Python Mutable Default Arguments: The Coffee Machine Trap
Mutable-Default-Arguments
Mutable Default Arguments in Python
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

Popular Post

graph-theory-planar-graph-amp-subgraph-and-spanning-amp-induced-graph
Graph Theory: Planar Graph & Subgraph and Spanning & Induced Graph
sql-exists-operator
Get Started: SQL EXISTS Operator
python-def-function
Introduction To Python Def Function with Practical Examples
turned on computer monitor displaying text
Network Security: Classical Encryption Techniques
python-binary-number-validation-conversion-methods
Python Binary Number: Validation & Conversion Methods
codingstreets-live-on-youtube

Top Articles

crop man taking notes in planner while working remotely in cafe with laptop
Network Security: Principles of Public Key Cryptosystems
woman working at home using her laptop
Introduction to Access Specifier in Java
letter blocks
What is Machine Learning? The Ultimate Beginner’s Guide
TOP 10 Oldest Programming Languages That Developers Are Searching For In 2022
person in black sweater hold a grey road bike
Data Structure Algorithm: Introduction to Queue
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