2017-03-03 87 views
-1

大家好,我有这个原始查询在mysql中我需要翻译成laravel 5.4查询构建器转换如何MySQL来laravel查询生成器

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 

我不知道如何查询生成器转换,其中clausule与2 colum

有什么想法?

THX所有

回答

0
$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 
); 
+0

THX @EddyTheDove)存在使用另一种方式 - > whare()或whareIn()查询生成器的方法是什么? – DaveIt

+0

如果你有一个ID数组,是的,你可以使用whereIn。但它并不像那样。你必须传递一个数组。 – EddyTheDove