原生sql

select 
    * 
from 
    homework 
where 
    (id between 1 and 10 or id between 50 and 70) 
    and complete = 1 
    and (title like 'a%' or title like 'b%');

ORM查詢

$homeworks = Homework::where(function ($query) {
    $query->whereBetween('id', [1, 10])
          ->orWhereBetween('id', [50, 70]);
})->where('complete', 1)
->where(function ($query) {
    $query->where('title', 'like', 'a%')
          ->orWhere('title', 'like', 'b%');
})->get();


来源:CSDN
原文:https://blog.csdn.net/xcqingfeng/article/details/80364618

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-05
猜你喜欢
  • 2021-05-29
  • 2021-08-13
  • 2022-12-23
  • 2021-07-09
  • 2022-12-23
相关资源
相似解决方案