Reputation: 1
Suppose I have a table named testdb
which has the following values:
| Name | Phone |ID |
|------------------|------------|---|
| supriyo roy | 9038689236 | 2 |
| supriyo banerjee | 8013147879 | 3 |
| Alex ghosh | 8985855665 | 4 |
Now, I am performing a search by the name and the input given is just "supriyo" (no last name given). The search result should show both the values:
| Name | Phone |ID |
|------------------|------------|---|
| supriyo roy | 9038689236 | 2 |
| supriyo banerjee | 8013147879 | 3 |
Is this possible to achieve using MySQL and php
?
Upvotes: 0
Views: 27
Reputation: 39507
You are looking for LIKE
:
select *
from your_table
where name like 'supriyo%';
In php, use:
select *
from your_table
where name like '$name%';
Upvotes: 3