A Gentle Introduction to

SQL

SELECT

Construct queries


How do you use Equi Join to join two tables with the same name?
I am trying to join two tables with the same name. I am required to use an inner join Also I need to show the managers name. Question is: Join the employee table with the employee table and department table. Show the employee id, name, dept code, manager id, manager name, managers department code, and name for that (mgr's) department.

We have a self join, each copy of the table is given an "alias" - here we use w for the worker and b for the boss. We can treat these as different tables.

You get an inner join by default - this means that Robin (who has no boss) does not show up in the results.

oracle variations:
None

access
db2
mysql
oracle
postgres
sqlserver