Results 1 to 3 of 3

Thread: How to get values from one table

  1. #1
    Junior Member
    Join Date
    Jun 2007
    Answers
    1

    How to get values from one table

    Let it be 1 table "employee" in database, having 3 attributes, "emp_id", "emp_name", "emp_boss".

    Employee
    emp_id - emp_name - emp_boss
    1 - abc - 2
    2 - xyz - 2
    3 - lmn - 1
    4 - pqr - 3

    Get employee name and his/her boss name


  2. #2
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: How to get values from one table

    Try this
    select emp_name,(select emp_name from employee where emp_id=a.emp_id) boss_name from employee a;


  3. #3
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: How to get values from one table

    You can also try this

    Code:
    select a.emp_name employee, b.emp_name manager from emp a ,emp b where a.emp_boss=b.empid
    This query uses self join.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact