Search code examples
mysqlzend-framework2any

Create a subquery using ALL and ANY statements


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?


Solution

  • 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