Lets say that i have a 3 tables:
Cars
- Id
CarColorHistory
- Id
- CarID
- ColorID
- ModificationDate
Color:
- Id
- ColorName
I want to select all cars and their colors but the important thing is, that color for the car is the last modified color from CarColorHistory
table.
I need to use join to do this.
Example:
Cars:
1
2
CarColorhistory:
1 1 1 26/03/2012 -> (actual color, can be take by date or id)
2 1 2 25/03/2012
3 2 2 25/03/2012
Color:
1 Blue
2 Red
I need to get result: (car id, colorName)
1 Blue
2 Red
I tried make it by joining Cars table and CarColorHistory table but I get cars for all colors. I need only actual color (last added).
Please help