vendredi 26 février 2016

Find matching keywords from comma separated

I am trying to find keywords from comma separating string with FIND_IN_SET and here is mysql query in Laravel framwork.

$Keyword = $_POST['keyword'];
$Result = DB::table('faqtopic')
    ->whereRaw('FIND_IN_SET(?,Keywords)', 'LIKE', ''[$Keyword])
    ->get();

faqtopic table:

╔════╦══════════════╗
║ id ║   keywords   ║
╠════╬══════════════╣
║  1 ║ php, android ║
║  2 ║ microsoft,net║
║  3 ║ android, ios ║
╚════╩══════════════╝

I am getting two results, If I pass android keyword but not getting any result I pass only andro. I want to get android result If user pass andro keyword for search query.

Any Idea how to get this results.

Thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire