This example illustrates how to use the like operator in sql query. The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.
This example illustrates how to use the like operator in sql query. The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.This example illustrates how to use the like operator in sql query. The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.
In the following code the "%" sign can be used to define wildcards (missing letters in the pattern) both before and after the pattern.
Table: emp

Source Code of likeOperator.php
<?php
|
Output:

In this query we want to find the name which start from s.
| $result = mysql_query("select * from emp where name like 's%'"); |

In this query we want to find the name which end with h.
| $result = mysql_query("select * from emp where name like '%h'"); |

In this query we want to find the name in which a must be available.
| $result = mysql_query("select * from emp where name like '%a%'"); |
