Have you looked in the documentation for creating joins?
Documentation: https://laravel.com/docs/7.x/queries#joins
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, I need a help i have three tables Product , loadings, and stocksin each tables have date,
I want to select the specific [ product id] and Fetch data from this table, loadings and stocksin in current month.
Product table
Id. Name
---------------------
1. P1
2. P2
3. P3
Loadings tables
Pid. Qty. outdate
1. 20. 2020-04-01
2. 10. 2020-04-01
3. 10. 20202-05-01
2. 30. 20202-05-02
Stockin tables
Pid. Qty. Indate
1. 20. 2020-04-01
2. 10. 2020-05-01
3. 10. 20202-05-01
2. 30. 20202-05-02
Example select id=2 Am Expect to have this
Items Date. Openbalance. LoadOut. Stock. Closed balance
P2 2020-05-01. 0. 30. 0. -30
Note:
Open balnc is the closed balance of previous day of current date Closed balance = open balance + stockin-loadout
How can i archive this even if you will use subquery of sql
Please or to participate in this conversation.