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
In reply to Re: SQL JOINs vs WHERE statements
by CountZero
in thread SQL JOINs vs WHERE statements
by Cody Pendant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |