Saturday, November 13, 2010

LIKE operator

LIKE operator is used for pattern matching.

e.g.

To find name and salary of employees whose first name starts with 'A':

SQL> select first_name,salary from employees where first_name like 'A%';

To find name and salary of employees whose first name starts with 'A' and followed by 3 characters:

SQL> select first_name,salary from employees where first_name like 'A___';



Have a question or comment? Post it below!


3 Comments:

Anonymous said...

Hello Sir,
I used the like operator and i have one question about it....as in example given above, if i want to find out the name and salary of employees whose first name starts with 'A' and 'D',then how to do that. I used'and' operator but its not working.....

Thanks,

Administrator said...

Try this:

SQL> select first_name from employees where first_name like 'A%' or first_name like 'D%';

Anuradha said...

ThankYou Sir....i missed to put first_name with 'D'.

Post a Comment