I have two tables, the first one looks like this:
[Comparisons]
- Id (int)
- Car_Id1 (int)
- Car_Id2 (int)
- Slug (string)
- TimeStamp
The second one:
[VehicleSpecs]
- Id (int)
- Year (int)
- Make (string)
- Model (string)
I have this query
SELECT TOP 100 *
FROM [Comparsions]
WHERE
ORDER BY [TimeStamp]
It returns the newest 100 records, but I need to replace the Car_Id1 and Car_Id2 with information from the second table like this: Car_Id1 -> [Year + Make + Model]
So what you’ll need is two
INNER JOINs against theVehicleSpecstable, one for eachCar_Id1andCar_Id2. I’ve aliased them ascar1, car2.You said you wanted the newest, so I assume you actually mean to use descending order on the timestamps: