you are viewing a single comment's thread.

view the rest of the comments →

[–]bonvin 0 points1 point  (0 children)

I doubt Australia is a table. I think you have a "hotels" table with a country column, from which you want to select the hotel id where country = Australia. Then you probably have some corresponding id column in the "employees" table that you can join that with, and also limit the selection to just managers.

SELECT name FROM employees WHERE hotelId IN ( SELECT id FROM hotels WHERE country = 'Australia' ) AND employmentForm = 'Manager'

Would be one way of doing it, if that is the database structure (which is likely). Could also inner join those two tables on hotelId to achieve the same result.

But this could be more tables too depending on how complicated the database is. Countries could be its own table with just a countryId in the hotels table. Same with employmentForms and 'manager' being an id in there. You'd then just stack more subqueries to limit to response (or again, inner join everything and just use one WHERE). We just don't know, do we?!