How to use Like operator in sql

SUMMARY


In this video tutorial we will learn how to use  Like operator in sql with wildcard character .



WHAT IS LIKE OPERATOR IN SQL


We use like operator for pattern search.There are two wildcard character " % " and " _ ".% is used to find from zero to any no of character._ is used to find for only one character. 


 First we need to login our mysql server . Then check all database list and select our preferred database.you select your database as per your requirement. In our case we select techrideradmin database . Then select the table list within the database. In our case we select department table. Now fetch all records form the table.



EXAMPLE OF LIKE OPERATOR IN SQL


We have solved some queries . You can see the video for reference.

1)Fetch the records whose first letter of ename is "A". For that purpose we use % wildcard .

mysql>Select * from department where ename like 'A%';

2)Fetch the records whose first two letters of ename is "AS".For that purpose we use % wildcard .

mysql>Select * from department where ename like 'AS%';

3)Fetch the records whose last letter of ename is "F".For that purpose we use % wildcard .

mysql>Select * from department where ename like '%F';


4)For any particular letter within the word we use _ character.

mysql > Select * from department where ename like 'AS_K';

Conclusion 

In this video tutorial we have learned  how to use  Like operator in sql with wildcard character .



SHARE

Admin

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment