I know it’s off-topic. But I’m sure you are using SQL and can help me
I’ve a table CARS and a table KEYS and a LOCKS table.
A car can have many keys. Keys are for different locks.
How can I get the cars which have at least the keys for locks like
So in the above example…
ford and mazda have keys for the same locks. So a query for mazda or
ford should return ford, mazda and porsche. audi is no result because it
misses the key for lock 2. porsche is a result because it has all keys
mazda or ford has plus a third key.
A query for audi should return all four because all cars in the example
have keys for lock 1 which is the only key audi has.
A query for porsche should only return porsche because it is the only
car which has the key for lock 3.
It is enough to get car_id results and the car_id for the car to query
Is it possible to handle a multiple row condition in SQL?