kaizokupuffball
2 weeks ago

Laravel union query using Eloquent and Query Builder

Posted 2 weeks ago by kaizokupuffball

This is my sample query that i want to implement in laravel Eloquent or Query Builder

SELECT in_records.item_id, 
       in_records.date, 
       in_records.value AS 'IN', 
       ''               AS 'OUT', 
       in_records.USER 
FROM   in_records 
UNION 
SELECT out_records.item_id, 
       out_records.date, 
       ''                AS 'IN', 
       out_records.value AS 'OUT', 
       out_records.USER 
FROM   out_records 
ORDER  BY date

Any help?

Please sign in or create an account to participate in this conversation.