MySQL - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

MySQL Like Clause

MySQL Like Clause

shape Description

MySQL LIKE Clause permits some special cases to be utilized as a part of the WHERE clause such as Insert, Delete, Select and Update proclamation. MySQL Like clause also permits execution of design coordination.

shape Syntax

The syntax for MySQL Like Clause is as follows:
Select <column_name1><column_name2>...<column_nameN>from <table_name> where <column_name> like <value>
Table name => Any accurate table name in the database. Column name => The column names that are inserted in the table. Condition => Specific logic.

shape Examples

By viewing the below example, the concept of MySQL Like Clause can be easily understood. [sql] mysql> select * from employee; +--------+-------+-------+--------+-----------+ | emp_id | ename |salary| deptno | job | +--------+-------+-------+--------+-----------+ | 1001 | mike | 12000 | 10 | manager | | 1002 | rambo | 13000 | 20 | scalesman | | 1003 | kate | 14000 | 10 | manager | | 1003 | jeo | 14000 | 20 | manager | | 1003 | finn | 14000 | 30 | manager | +--------+-------+-------+--------+-----------+ 5 rows in set (0.00 sec) mysql> select * from employee where ename like '%bo'; +--------+-------+-------+--------+-----------+ | emp_id | ename | salary| deptno | job | +--------+-------+-------+--------+-----------+ | 1002 | rambo | 13000 | 20 | scalesman | +--------+-------+-------+--------+-----------+ 1 row in set (0.10 sec) mysql> select * from employee where ename like '%n'; +--------+-------+-------+--------+-----------+ | emp_id | ename | salary| deptno | job | +--------+-------+-------+--------+-----------+ | 1003 | finn | 14000 | 30 | manager | +--------+-------+-------+--------+-----------+ 1 row in set (0.10 sec)[/sql] Here in the above example, the Like clause will permit to match any string of length characters.

Summary

shape Key Points

  • MySQL Like Clause - Permit to match any string of length characters.