SQL LIKE and NOT LIKE Conditions

Last updated: August 26, 2026.

The SQL LIKE condition matches text using wildcard patterns. A percent sign matches zero or more characters; an underscore matches exactly one character.

SELECT customer_id, company_name
FROM customers
WHERE company_name LIKE 'A%';

Common patterns

PatternMeaning
'A%'Starts with A
'%son'Ends with son
'%market%'Contains market
'A_3'A, one character, then 3
SELECT product_id, product_name
FROM products
WHERE product_name NOT LIKE '%sample%';

Case sensitivity depends on the database and collation. Bind a parameter instead of concatenating user input, and escape wildcard characters when the search term should be treated literally.

admin

admin

Leave a Reply

Your email address will not be published.