SQL LIKE Operator Explained: How to Search Text Patterns in Databases
SQL's LIKE operator allows developers to search for text patterns within database columns, unlike the equality operator which requires an exact match. It uses two wildcards: the percent sign (%) to represent any sequence of characters including none, and the underscore (_) to represent exactly one character. For example, querying WHERE name LIKE '%Shirt%' returns all rows containing the word 'Shirt' anywhere in the column, while the equals operator would only return rows where the entire value is 'Shirt'. Wildcards can be combined to match structured formats such as product codes or account numbers where the pattern is fixed but content varies. Adding NOT before LIKE reverses the filter, returning all rows that do not match the specified pattern.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in