MySQL Forums
Forum List  »  MySQL Query Browser

Re: Query Fails - Need Help Figuring it out
Posted by: Scott Nemes
Date: February 10, 2012 10:51AM

The below will work:

create view EmployeeBoss (empoyee_number, employee_name, employee_salary, boss_name) as select empl.empno, empl.empname, empl.empsalary, IF(ISNULL(mgr.empname), "None", mgr.empname) from emp empl left join emp mgr on empl.bossno = mgr.empno;

I added in extra logic to account for employees with no boss, but you should be able to modify it as needed. =)

--
Scott Nemes
MySQL DBA

http://www.linkedin.com/in/scottnemes
http://www.twitter.com/ScottNemes

Options: ReplyQuote


Subject
Written By
Posted
C R
February 10, 2012 06:38AM
Re: Query Fails - Need Help Figuring it out
February 10, 2012 10:51AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.