I have a Transaction table and a Car table.
tID | cID | carID | eID | tDate | PickupDate | ReturnDate | Amount_Due |
---|---|---|---|---|---|---|---|
1002 | 1006 | 1004 | 104 | 2018-04-18 | 2018-04-28 | 2018-04-2 | NULL |
Car
CarID | Make | Model | Type | Year | Price |
---|---|---|---|---|---|
1004 | Ford | Focus | Hatch | 2019 | 140.00 |
I need to update the Amount due column with Price * DATEDIFF(day, [Transaction].PickupDate, [Transaction].ReturnDate)
I know I need an inner join but not sure how to write the query correctly. This is what i have so far but I think it's way off. I'm very new to SQL
UPDATE [Transaction]
SET Amount_Due = INNER JOIN CAR ON [Transaction].carID=Car.carIS * (DATEDIFF(day, [Transaction].PickupDate, [Transaction].ReturnDate))