如何将mysql转换为laravel查询生成器

时间:2017-03-03 08:52:05

标签: php mysql laravel laravel-5.4

大家好我在mysql中有这个原始查询我需要翻译成laravel 5.4查询构建器

select * from pages where (phase_id, type) in (select max(phase_id),type from pages where phase_id<=2 and actived=1 group by type) and actived=1

我不知道如何在查询构建器中转换where claumule with 2 colum

任何想法?

全部

1 个答案:

答案 0 :(得分:1)

$results = DB::select(
    select * from pages where (phase_id, type) 
    in (
        select max(phase_id), type 
        from pages 
        where phase_id <= 2 
        and actived = 1 
        group by type
    ) 
    and actived = 1
);