The SQL LIKE operator is used in a WHERE clause to search for a specified pattern in a column.It allows you to search for data that matches a specified pattern The pattern can include two wildcard characters:
SELECT * FROM employeesWHERE name LIKE 'R%';
SELECT * FROM employees
WHERE name LIKE 'R%';
Query Will Search Name From Employees Table That Start With “R” And Return All Name Start With “R”
SELECT * FROM employeesWHERE name LIKE '%R';
WHERE name LIKE '%R';
Query Will Search Name From Employees Table That End With “R” And Return All Name End With “R”
SELECT * FROM employeesWHERE name LIKE '%R%';
WHERE name LIKE '%R%';
Query Will Search Name From Employees Table That Have “R” In Any Position And Return All Name Having “R” In Any Position
SELECT * FROM employeesWHERE name LIKE '%A_';
WHERE name LIKE '%A_';
Query Will Search Name From Employees Table Second Last Letter Of Name Is “A” Return All Name Which Having Second Last Letter With “A”
The SQL LIKE operator is used in a WHERE clause to match a specified pattern in a column of a table. It is often used with wildcard characters such as “%” to represent any sequence of characters, or “_” to represent any single character. The syntax for the LIKE operator is as follows:
SELECT column_nameFROM table_nameWHERE column_name LIKE pattern;
SELECT column_name
FROM table_name
WHERE column_name LIKE pattern;
For example, the following query returns all rows from the “customers” table where the “city” column starts with “Londo”:
SELECT * FROM customersWHERE city LIKE 'Londo%';
SELECT * FROM customers
WHERE city LIKE 'Londo%';
The SQL LIKE condition allows you to use wildcards to perform pattern matching in a query. The LIKE condition is used in the WHERE clause of a SELECT statement.