jeudi 10 octobre 2019

how to make laravel query using find_in_set

How to get the desire output using laravel query. Tried that way does not get success please guide thanks a lot in advance

Is there any way we can set it in model if possible please guide

User

id  name    b_id
1   Alax    1,3
2   Rex 2,4
3   Lex 2,3

Books

id  book_name   
1   Javascript
2   PHP 
3   LARAVEL
4   SYMPHONY

Output

id  name    b_id
1   Alax    Javascript, LARAVEL
2   Rex PHP, SYMPHONY
3   Lex PHP, LARAVEL

$res = DB::table('user')->leftJoin('book', function($join){
   $join->on(DB::raw("find_in_set(book.id, user.b_id)",DB::raw(''),DB::raw('')));
});


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire