Closed
Description
I'm trying to write a QueryInterfaceRequest
for a self-join on a table on a single column and coming up short. I would greatly appreciate your assistance.
Assume the following model:
struct PetSitter {
let petId: Int
let sitterId: Int
}
The SQL query I'm trying to replicate in the record API looks like this:
select ps.sitterId from petSitter ps
inner join petSitter ps1 on ps.petId = ps1.petId
where ps1.sitterId in (1, 2, 3)
In plain English, "Find all the sitters who pet-sit the pets that pet sitters 1, 2, 3 pet-sit." It's sort of a transitive closure over a set of pet sitters via the pets they sit.
Does my question make sense?