I'm trying to do an inner join between 3 tables in an ERD I created. I've successfully built 3 - 3 layer sub-queries using these tables, and when I researched this issue, I can say that in my DDL, I didn't use double quotes so the columns aren't case sensitive. Joins aren't my strong suite so any help would be much appreciated. This is the query im putting in, and the error it's giving me. All of the answers I've seen when people do inner joins they use the syntax, 'INNER JOIN' but I wasn't taught this? Is my method still okay?
SQL>
SELECT regional_lot.location,
rental_agreement.vin,
rental_agreement.contract_ID
FROM regional_lot,
rental_agreement
WHERE regional_lot.regional_lot_id = vehicle1.regional_lot_ID
AND vehicle1.vin = rental_agreement.vin;
*
ERROR at line 1:
ORA-00904: "VEHICLE1"."VIN": invalid identifier
For starters, you don't have vehicle1
in your FROM
list.
You should give ANSI joins a try. For one, they're a lot more readable and you don't pollute your WHERE
clause with join conditions
SELECT regional_lot.location, rental_agreement.vin, rental_agreement.contract_ID
FROM rental_agreement
INNER JOIN vehicle1
ON rental_agreement.vin = vehicle1.vin
INNER JOIN regional_lot
ON vehicle1.regional_lot_ID = regional_lot.regional_lot_id;