jeudi 13 septembre 2018

Translating an sql statement with multiple select into laravel

Please I am having issues running this below code raw on laravel.

SELECT p.id, p.user_id,  from 
   (select followee_id as id  
   from 
   followings fl where follower_id =12
   union 
   select sender_id  from friends f 
   where f.receiver_id =12 AND accepted=1
   union
   select receiver_id from friends f 
   where f.sender_id  =12 AND accepted=1) 
as t join picture_galleries p on t.id=p.user_id

I tried running the above query raw in laravel and did a test run with postman buy I keep getting this message here is the link to the error message

Here is my code

DB::select('SELECT p.id, p.user_id,  from 
        (  select followee_id as id  from followings fl 
           where follower_id =12
            union 
           select sender_id  from friends f where f.receiver_id =12 
           AND accepted=1
           union
          select receiver_id from friends f where f.sender_id  =12 
          AND accepted=1
          ) as t join video_statuses p on t.id=p.user_id'
        )->first();



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Mv3nLt
via IFTTT

Aucun commentaire:

Enregistrer un commentaire