簡體   English   中英

用於 MYSQL 查詢的 Laravel 查詢生成器

[英]Laravel Query Builder For MYSQL Query

請我需要與此 mysql 查詢等效的 laravel 查詢構建器:

SELECT * from shifts WHERE staffs LIKE (select CONCAT("%", id, "%") FROM users where email = 'turner.alexandra@gmail.com')

以上查詢

終於有答案了

//Get the id from user Table
  $users =  User::where('email', $email)->get();
  foreach($users  as $user)
  {
   $id = $user->id;
  } 
//Use The Id to Get the Result
  $availableShift = DB::table('shifts')
                    ->select('*')
                    ->where('staffs', 'LIKE', '%'.$id.'%')
                     ->paginate(2);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM