I have the following tables in the database (I will list only the important attributes):
Person(ssn,countryofbirth) Parents(ssn,fatherbirthcountry) Employment(ssn, companyID) Company(companyID, name)
My task is this: taking into account the parental homeland as input, output the names of the companies in which people work, whose native origin corresponds to the entry of the father-father.
I pretend my father is Mexico and does this:
SELECT name FROM Company WHERE companyid = (SELECT companyid FROM Employment WHERE ssn = (SELECT ssn FROM Person WHERE countryofbirth = 'Mexico');
but this gives me an error:
>Scalar subquery is only allowed to return a single row.
Am I completely unaware? Can anybody help?
source share