posted 14 years ago
I've been asked to modify an Oracle query. While I have fundamentatl SQL skills - my sophistication could use some improvement..
Here's a query (it's for example purposes):
select tbl3.emp_name,
tbl3.emp_fullname,
tbl4.emp_fullname,
tbl4.emp_name
from table1 tbl1,
table2 tbl2,
employee tbl3,
employee tbl4
where tbl2.org_name like '%HOME%'
and tbl1.org_home_team = 'Y'
and tbl3.emp_id = tbl1.emp_id
and tbl1.emp_id = tbl4.emp_id
and tbl2.wbt_id = tbl1.wbt_id
and sysdate between tbl4.EMP_EFFECTIVE_DATE and tbl4.EMP_TERMINATION_DATE;
My question - tbl3.emp_name and tbl4.emp_name both point to the same column in the same table; when when the query is run they yield different information. I was surprised to see the same table mentioned twice in the same query, then I saw the same column names.
How is that different information is retrieved. Any explanation here would be appreciated. Thanks!