lalavel8 サブクエリー (クエリビルダー)


 $sql = "SELECT ←普通のSQL文
 FROM
 WHERE " ; 
 

 DB::table('app_user_user AS uu')
        ->select( ~ ~ 

    ) ->leftJoin( DB::raw("( $sql  ) AS sc ") , 'uu.id', '=', 'sc.user_id')


	$juhuku = DB::table('issuers')
		->orWhere(function($query) {
			$query->where('tel', $this->tel[$this->j])
			->where('user_id', '!=', $this->user_id);
		})
		->orWhere(function($query) {
		$query->where('email', $this->email[$this->j])
		->where('user_id', '!=', $this->user_id);
	})->exists() ;



select exists( select * from `issuers` where ( `tel` = '230-0234-5432' and `user_id` != 4604 ) or ( `email` = 'izumo@reqw.wer' and `user_id` != 4604) ) as `exists`


Categories:

Tags: