PadhaiTime Logo
Padhai Time

Text Starts with and Ends with in SQL

There can be some scenarios where you need to pull all the records from the database where the values of a particular column starts or ends with a specific character. To solve cases like these, there is a special character known as percentile%” which is being used.

 

Let us take a look at data first and then we will cover few cases:

 

Query:

SELECT * FROM Employee;

Output:

undefined

 

Problem 1: Write a SQL query to get all the employees whose name start with “J”

Query: 

SELECT * FROM Employee
WHERE name Like 'j%';

Output:

undefined

 

Problem 2: Write a SQL query to get all the employees whose name end with “n”

Query:

SELECT * FROM Employee
WHERE name Like '%n';

Output:

undefined

 

Problem 3: Write a SQL query to get all the employees whose name start with “J” and end with “e”

Query:

SELECT * FROM Employee
WHERE name Like 'j%E';

Output:

undefined

 

Point to Remember:

String matching is case insensitive. All of these search terms “j%E”, “J%E”, “J%e”, “j%e” will behave exactly the same.

Bengaluru, India
contact.padhaitime@gmail.com
  • We collect cookies and may share with 3rd party vendors for analytics, advertising and to enhance your experience. You can read more about our cookie policy by clicking on the 'Learn More' Button. By Clicking 'Accept', you agree to use our cookie technology.
    Our Privacy policy can be found by clicking here