I am not sure I can explain this, so I will try my best.
I have 3 tables, orders, movements and movement_order,
movement_order ties an order to multiple movements. Let's call one movement loaded and one empty.
movement_order fields:
id, order_id, movement_id
1, 100, 200
2, 100, 201
3, 101, 202
4, 101, 203
I want to search for an order, and get both the loaded and empty distance for that order. The "distance" is stored in the movement table.
I know that I have to link orders -> movement_order -> movement to get details about an move for an order. I have wrote a query that does this for me. The problem I run into is I am not sure how to do this "again" to get the the other information I need, the information about the 2nd move.
Prefered results:
order_id, loaded distance, empty distance
100, 250, 25
I guess my question is, how do I do this so I can return both the loaded move distance and empty move distance in one record?
As I said, I am sure this is not explained very well, I know what I want to do, just hard to explain it.
Please let me know if there is any more information that might be helpful here.
I have 3 tables, orders, movements and movement_order,
movement_order ties an order to multiple movements. Let's call one movement loaded and one empty.
movement_order fields:
id, order_id, movement_id
1, 100, 200
2, 100, 201
3, 101, 202
4, 101, 203
I want to search for an order, and get both the loaded and empty distance for that order. The "distance" is stored in the movement table.
I know that I have to link orders -> movement_order -> movement to get details about an move for an order. I have wrote a query that does this for me. The problem I run into is I am not sure how to do this "again" to get the the other information I need, the information about the 2nd move.
Prefered results:
order_id, loaded distance, empty distance
100, 250, 25
I guess my question is, how do I do this so I can return both the loaded move distance and empty move distance in one record?
As I said, I am sure this is not explained very well, I know what I want to do, just hard to explain it.
Please let me know if there is any more information that might be helpful here.