Question:

What is the purpose of % and _ (underscore) characters used with LIKE operator in SQL?

Show Hint

Use % to match any number of characters and _ to match exactly one character in SQL.
Updated On: Jul 14, 2025
Hide Solution
collegedunia
Verified By Collegedunia

Solution and Explanation

In SQL, the LIKE operator is used in the WHERE clause to search for a specified pattern in a column.
To make pattern matching flexible, two wildcard characters are used with LIKE:
(i) % (Percent sign): Represents zero, one, or many characters.
For example: SELECT * FROM employees WHERE name LIKE 'R%';
This will match any name starting with the letter 'R', such as Rahul, Rina, or Robert.
(ii) _ (Underscore): Represents exactly one character.
For example: SELECT * FROM users WHERE code LIKE 'A_1';
This matches values like A01, AB1, or AZ1.
These wildcards help in filtering records based on partial matches rather than exact strings.
Was this answer helpful?
0
0

Top Questions on SQL

View More Questions