SQL, SQL Server, Tutorials, Oracle, PL/SQL, Interview Questions & Answers, Joins, Multiple Choice Questions, Quiz, Stored Procedures, Select, Insert, Update, Delete and other latest topics on SQL, SQL Server and Oracle.
SQL LIKE
SQL LIKE
The SQL LIKE operator is used in a WHERE clause to look for a particular pattern in a column.
Examples of SQL LIKE
Now we want to select the employees which have their names starting with "s".
SELECT * FROM employees
WHERE ename LIKE 's%'
We want to select the employees which have their names ending with "s".
SELECT * FROM employees
WHERE ename LIKE '%s'
We are looking for all employees whose name contains the characters 'sam'
SELECT * FROM employees
WHERE ename LIKE '%sam%'
This SQL statement would return all employees whose name is 5 characters long, where the first two characters is 'Sm' and the last two characters is 'th'. For example, 'Smith', 'Smyth', 'Smath', 'Smeth', etc.
SELECT * FROM employees
WHERE ename like 'Sm_th';
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment