Laravel 5 (Eloquent) JOIN between two queries, is it possible?

0

The following SQL performs two queries and "adds" the hard answers "sideways":

 select * from (select id,name from client  where id = 20) as a

 join  (select id,age from client  where id = 20) as b

 ON a.id = b.id

I wonder if it's possible to do this using eloquent, without using pure SQL (DB :: Raw ()).  The two separate queries would look like this:

 $query1 = DB::table('client')->select('id','nome')->where('id','=',20);
 $query2 = DB::table('client')->select('id','age')->where('id','=',20);

Now, how to do it:

 $query1->join($query2)...:

Before you tell me the obvious "you can have the same answer in a single query", this is just an example, in the real context, I believe it is not possible to bring all the information at once.

    
asked by anonymous 15.04.2016 / 21:40

0 answers