Learn how to use MySQL LIKE & Wildcards (% and _) to filter data in powerful ways!
In this 60-second tutorial, you’ll see how to:
Find names starting or ending with specific letters
Search with partial matches
Use _ for single-character matching
Perfect for SQL beginners and developers who want quick and practical examples.
-- MySQL LIKE & Wildcards
-- Create table users
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50),
email VARCHAR(100)
);
-- Insert sample data
INSERT INTO users (name, email) VALUES
('Alice', '[email protected]'),
('Alex', '[email protected]'),
('Amanda', '[email protected]'),
('Brian', '[email protected]'),
('Bella', '[email protected]'),
('Charlie', '[email protected]'),
('David', '[email protected]');
-- 1. Find names that start with 'A'
SELECT * FROM users
WHERE name LIKE 'A%';
-- 2. Find names that end with 'a'
SELECT * FROM users
WHERE name LIKE '%a';
-- 3. Find names that contain 'li'
SELECT * FROM users
WHERE name LIKE '%li%';
-- 4. Find names where the second letter is 'l'
SELECT * FROM users
WHERE name LIKE '_l%';
-- 5. Find names with exactly 5 characters
SELECT * FROM users
WHERE name LIKE '_____';
#mysql #sql #database #shorts #shortsfeed