moody moody - 1 year ago 88
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?

Answer Source

You could use the in operator:

FROM   persons
WHERE  CompanyId IN (SELECT CompanyId
                     FROM   company
                     WHERE  CompanyTypeId = 2)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download