Login

Username:

Password: 

Join us Now |  Forgot Password? | Forgot UserName?

SQL

Learn step by step



SQL - LIKE Clause

The SQL LIKE clause is used to compare a value to similar values using wildcard operators.
There are 2 wildcards used in conjunction with the LIKE operator:

  • The percent sign (%)
  • The underscore (_)

Syntax

select from table where
column LIKe 'xyz%'
OR
SELECT FROM table_name
WHERE column LIKE '%xyz%'
OR
SELECT FROM table_name
WHERE column LIKE 'xyz_'
OR
SELECT FROM table_name
WHERE column LIKE '_xyz'

We will use Customers table to illustrate the SQL LIKE clause usage:
In SQL LIKE clause is very useful when we want to specify a search condition within our SQL WHERE clause, based on a part of a column contents. Example if we want to select all customers having FirstName starting with 'J' we need to use the following SQL statement:

Table Customer

FirstName LastName Email DOB Phone
Jagdish Jain jagdish@yahoo.com 6/12/1988 45234523
Ramesh Patel ramesh@gmail.com 7/12/1988 147852258
Rahul Tanvar rahul@gmail.com 5/24/1988 233-234-234
Jai Soni js@gmail.co.uk 20/12/1990 789525


SELECT *
FROM Customers
WHERE FirstName LIKE 'J%'

Output

FirstName LastName Email DOB Phone
Jagdish Jain jagdish@yahoo.com 6/12/1988 45234523
Jai Soni js@gmail.co.uk 20/12/1990 789525


Related Videos