Wildcards in MySQL are used with the LIKE operator to search for specified patterns inside text columns. They allow flexible pattern matching (partial matches, fixed-length matches) which is useful for filtering results without full-text search.
%term) can prevent index usage and slow queries on large tables.
-- General LIKE syntax
SELECT column_name
FROM table_name
WHERE column_name LIKE pattern;
-- Find records where the 'name' starts with 'A'
SELECT * FROM students
WHERE name LIKE 'A%';
-- Find records where the 'name' ends with 'son'
SELECT * FROM students
WHERE name LIKE '%son';
-- Find records where the 'name' contains 'an' anywhere
SELECT * FROM students
WHERE name LIKE '%an%';
-- Match names with exactly 4 characters starting with 'J' (J + 3 single-character wildcards)
SELECT * FROM students
WHERE name LIKE 'J___';
LIKE 'A%' matches A, Adam, Alice, etc.LIKE '%son' matches Jackson, son, Emerson.LIKE '%an%' matches any string containing an (e.g., Andrew, Susan).LIKE 'J___' matches any 4-letter name starting with J (e.g., John, Jill).column LIKE 'term%' (no leading %) when possible to allow index use.% or _.LIKE to find records with a specific substring anywhere in the text (e.g., 'art')._ wildcard to match names with exactly 4 characters, not starting with a specific letter.