moody moody - 5 months ago 27
MySQL Question

mysql request retrieve data combined with 2 tables

U have three tables

enter image description here

I would like to request all persons, where the companyTypeID is for example '2'. How can I query that?


You could use the in operator:

FROM   persons
WHERE  CompanyId IN (SELECT CompanyId
                     FROM   company
                     WHERE  CompanyTypeId = 2)