Comma seprated search in mysql query
- by Ravi Kotwani
I have search mechanism in my site. For that I have written a large conditional query.
$sql = "select * from users where
keyword like '%".$_POST['search']."%'
OR name like '%".$_POST['search']."%'";
Now, I suppose I have following data on the site:
ID Name Keyword
1 Sanjay sanjay, surani
2 Ankit ankit, shah
3 Ravi ravi, kotwani
Now, I need the result such that when user writes "sanjay, shah" ($_POST['search'] = 'sanjay, shah') then records 1 and 2 should be displayed.
Can I achive this in single mysql query?