Create a subquery using ALL and ANY statements

27 views Asked by At

I'm trying to make this query

SELECT * FROM district 
WHERE id = ANY (SELECT districtId FROM address 
WHERE id = ANY (SELECT addressId FROM schedule
WHERE workshopId = '1'))

My real problem is inserting the ANY statement. Does anyone know how to apply ANY or ALL to the query in Zend Framework 2?

1

There are 1 answers

2
jorge polanco On BEST ANSWER

Why don't you use join tables?

select * from distrinct as d
join address as a using(districtId)
join schedule as s on s.addressId=a.addressId and s.workshopId = '1';

regards