Operator in SQL

LIKE Operator in SQL

LIKE operator is pattern matching In SQL. LIKE means Not Exactly just match some pattern for example when we use IN or BETWEEN or in Equal To (=) relational operator, then the Complete value compare if its match the whole value which is given in Condition then Its return other wise not. But in like operator we just provide a part of text and ask to match this part of text with whole text.

 We use percentage % and underscore _ wildcards with like operator. Where % is substitutes for zero or more characters and _ are used as substitutes of any single character.

For example from table given below:

Actual Table

client_name city order_amount
Syed Tauqeer Karachi 50000
Muhammad Zia Ahmed Lahore 20000
Noman Bloch Karachi 30000
Imran Hadir Islamabad 10000
Muneer Bloch Karachi 15000
Muhammad Zia Khan Islamabad 30000

 

SELECT  *  FROM client_info WHERE client_name like '%Bloch'

This statement show that second part of name or last part of name is Bloch and before the Bloch we did not know

The above statement display the following record.

Selected record with BETWEEN Operator

client_name city order_amount
Noman Bloch Karachi 30000
Muneer Bloch Karachi 15000

 

Read more about the Use of percentage % and underscore _ wildcards with LIKE operator