in reply to SQL JOINs vs WHERE statements
Consider the following situation (slightly adapted from an example in the MySQL docs):
You have a staff table that contains both staff and manager's details. If you wanted a list of staff, with their corresponding manager's details as well, you would refer to the same table twice, in essence joining the table to itself. eg.SELECT s1.StaffId, s1.StaffName, s1.Position, s1.ManagerId, s2.StaffNa +me AS ManagerName, s2.Position AS ManagerPosition FROM staff AS s1 INNER JOIN staff AS s2 ON(s1.ManagerId=s2.StaffId)
Would you be able to do that with a WHERE clause instead of a JOIN?
And how would you limit the results to all staff with position x?
CountZero
"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: SQL JOINs vs WHERE statements
by demerphq (Chancellor) on Aug 18, 2003 at 22:11 UTC | |
by CountZero (Bishop) on Aug 19, 2003 at 20:59 UTC |