Laravel雄辩地生成子查询

时间:2020-08-20 08:36:33

标签: laravel-7.x

我想生成一个如下的SQL查询:

select *
from ocs
where ocs.wfx_oc_no = 'OC11' and
ocs.id in (select id
          from buyers
          where buyers.buyer_code = 'B01')

有人可以通过laravel子查询来帮助我吗?

1 个答案:

答案 0 :(得分:0)

$ data = OCS :: where('wfc_oc_no','OC11')-> where('id',Buyers :: where('buyer_code','B01')-> first())-> get( );