Multiple Non-Equi JOINs Practice - self join table pe join on non-equi join and not primary key

PHOTO EMBED

Wed May 10 2023 00:59:01 GMT+0000 (Coordinated Universal Time)

Saved by @vnmshenoy #undefined

my ansewr worked

select c.model,c.brand,c.mileage,c.prod_year
from car c 
where c.prod_year  > (select prod_year from car  where id=2)
and c.original_price > (select original_price from car  where id=1)
------------

their  answer
SELECT
  c1.model,
  c1.brand,
  c1.mileage,
  c1.prod_year
FROM car c1
JOIN car c2
  ON c1.prod_year > c2.prod_year
JOIN car c3
  ON c1.original_price > c3.original_price
WHERE c2.id = 2
  AND c3.id = 1
content_copyCOPY

3 times self join ..i did it using inner query. One thing i was always doing when self join was that i was joining on the primary key of self join tables something like c.id = c1.id. however in the their answer, they don't do that. see above , how they join on non-equi joins (and not id's but prod_year eg c1.prod_year > c2.prod_year)

https://learnsql.com/track/sql-practice/course/joins/challenge/challenge-time/exercise-6