Sql Query To Use a ' SELECT ' statement with LIKE Clause


To retrieve a record having a specific pattern in a record from the existing created table. Then we can use a ' WHERE ' Clause with LIKE Operator.

  1. % - In 1st statement, it will retrieve the first_name having specific syntax “ra” in it from the table employees.
  2.  _ - In 2nd  statement,it will retrieve the first_name having specific syntax “ar” in it with one character below it and as many as character above it, from the table employees.
  3.  _ and __ - In 3rd  statement,it will retrieve the first_name having specific syntax “ar” in it with one character below it and two character above it, from the table employees.
  4. %a _r% - In 4th  statement,it will retrieve the value that having one character between a and r, start and end with any number of characters below and above a_r, from the table employees.
Enter - Select * from table_name;
SQL Query
SELECT 'Like Clause with % is used above and below ar'; SELECT * FROM employees WHERE first_name LIKE '%ra%'; SELECT 'Like Clause with _ and % is used below and above ar respectively'; SELECT * FROM employees WHERE first_name LIKE '_ar%'; SELECT 'Like Clause with _ is used below and __ is used above ar'; SELECT * FROM employees WHERE first_name LIKE '_ar__'; SELECT 'Like Clause will retrieve the value that having one character between a and r, start and end with any number of characters below and above a_r'; SELECT * FROM employees WHERE first_name LIKE '%a_r%';
Output