Query format

  • I have 2 tables Dept & Employee. DeptID is refered from Employee.

    The structure is like this

    DeptIDPK

    DeptName

    EmpIDPK

    EmpDepFK

    EmpName

    "Select DeptName,EmpName from Dept,Emplyee Where EmpDepFK = DeptIDPK"

    This query gives...

    Sales Jack

    Sales Joe

    Sales Don

    Admin Chapman

    Admin Dave

    Admin Steve

    But I want it like

    Sales Jack

    Joe

    Don

    Can anybody help in this regard

    thanks in advance

  • raveen4u (6/30/2009)


    I have 2 tables Dept & Employee. DeptID is refered from Employee.

    The structure is like this

    DeptIDPK

    DeptName

    EmpIDPK

    EmpDepFK

    EmpName

    "Select DeptName,EmpName from Dept,Emplyee Where EmpDepFK = DeptIDPK"

    This query gives...

    Sales Jack

    Sales Joe

    Sales Don

    Admin Chapman

    Admin Dave

    Admin Steve

    But I want it like

    Sales Jack

    Joe

    Don

    Can anybody help in this regard

    thanks in advance

    Select DeptName,EmpName from Dept inner join Emplyee ON Emplyee.EmpDepFK = Dept.DeptIDPK

    check this if this is what you need.

    For faster and better answers, i suggest you go through this link.

    http://qa.sqlservercentral.com/articles/Best+Practices/61537/%5B/url%5D



    Pradeep Singh

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply