Created
December 1, 2018 17:18
-
-
Save koras/af887a30d100b7843c5f9c6d81548ccb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// (SQL: select (select `user`.`id` from `user` where `user`.`id` in (2013, 2015) limit 1) | |
// as ff from `user` as `tmp_user` | |
// where `tmp_user`.`year` in (?, ?)) | |
public function arrayUser(){ | |
$arrayUser = [5,6]; | |
$arrayYear = [2013,2015]; | |
$subSelect = DB::table('user') | |
->select('user.id') | |
->wherein('user.id',$arrayUser) | |
->limit(1) | |
->toSql(); | |
DB::table('user as tmp_user') | |
->select( DB::raw('('.$subSelect.') as ff') | |
) | |
->wherein('tmp_user.year',$arrayYear) | |
->get(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment