Sir Phoenix
Board Regular
- Joined
- Aug 30, 2006
- Messages
- 146
I have two entities. A truck and some truck parts.
A truck can have many parts.
I have a query that tells me info about the truck, as well as how much total time is left on the truck's parts. To do this, I take the sum of the 'time left' on each truck part, then group it by truck.
However, I have two issues.
I need to see all trucks, even if they don't have any parts. An inner join excludes these trucks.
If I try to solve the above with a left join (show all trucks, and show all matching parts), I get an error, I assume from trying to SUM a field that doesn't exist. (In the case of trucks without parts)
How do I solve this?
A truck can have many parts.
I have a query that tells me info about the truck, as well as how much total time is left on the truck's parts. To do this, I take the sum of the 'time left' on each truck part, then group it by truck.
However, I have two issues.
I need to see all trucks, even if they don't have any parts. An inner join excludes these trucks.
If I try to solve the above with a left join (show all trucks, and show all matching parts), I get an error, I assume from trying to SUM a field that doesn't exist. (In the case of trucks without parts)
How do I solve this?