[Solved] SQL Print the name of all Employees together with the name of their supervisor


An inner join should do it. Here’s the syntax, but you’ll have to apply it to your database:

SELECT c.name, o.name
FROM cats c
INNER JOIN owners o
ON c.owner_id = o.id

“cats c” basically means “Cats table, which I’m nicknaming c.” “owners o” basically means “Owners table, which I’m nicknaming o.” In your select, you tell it which fields you want by their name, and which table their in: [table nickname].[fieldname]. The ON is where you specify a common field from each table, which tells it how to join the two tables together. In the case of this example, we’re saying that we want the owner who’s id is equal to the owner id field of the cats table. The owner_id field is a foreign key of the owners table.

I know answers like this are frustrating when you’re learning, but the truth is you’ll learn better if you have to figure a bit out for yourself, and I can’t do your homework for you (I mean that nicely..)

1

solved SQL Print the name of all Employees together with the name of their supervisor