Why is the SQL Wildcard (LIKE) Operator in the query?
336
18-Jul-2024
Updated on 18-Jul-2024
Ashutosh Kumar Verma
18-Jul-2024SQL LIKE Operator
The SQL LIKE function, with its wildcards, is used to match patterns in queries. Allows you to search for values that match a specific pattern in a column. This is useful when you want to see a partial similarity between data or records in a particular sample.
Wildcards used are ‘LIKE’
‘
%
’- Represents zero or more characters. For example, LIKE 'A%' matches any value starting with 'A'.‘
%%
’- Represents zero or more characters. e.g. LIKE ‘%A%’ matches all values that contain ‘A’‘_’
- Represents a single character. For example, LIKE 'A_ _
' matches any three-character value beginning with 'A'.‘
[]
’- Represents any single character within the brackets.‘
^
’- Represents any character not within the brackets.Example-
This query retrieves all the rows from the
People
table that contains ‘A’ in the columnFirstName
Also, Read: What are SQL Clauses and Operators?