Like
Jump to navigation
Jump to search
How do I use LIKE in a sql SELECT statement.
schema:scott
The LIKE command allows "Wild cards". A % may be used to match and string, _ will match any single character.
The example shows countries begining with Z. The country Zambia matches because ambia matches with the %.
DROP TABLE bbc;
DROP TABLE actor;
CREATE TABLE bbc (name VARCHAR(10), region VARCHAR(10));
INSERT INTO bbc VALUES ('Poland', 'Europe');
INSERT INTO bbc VALUES ('Japan', 'Asia');
INSERT INTO bbc VALUES ('Zambia', 'Africa');
SELECT name FROM bbc
WHERE name LIKE 'Z*'
SELECT name FROM bbc
WHERE name LIKE 'Z%'