[英]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.