Join query (How to join to tables)

  • Hi,

    I have two tables:

    one is Department - DepartmentName, DepartMentID

    and other is Employee - EmpName, EmpAdd, DepartmentID,etc. (There are 15 columns in Employee Table)

    What I want is

    All the columns from Employee Table and DepartName from Department table where DepartmentID is from Employee Table (Employee.DepartmentID)

    In result DepartmentName column should combine with columns from Employee Table.

    This is urgent, Please suggest how to do it.

    Thanks, Swapnil

     

  • select d.DepartmentName, e.EmpName, e.EmpAdd, e.DepartmentId, ...etc

    from Department d

    join Employee e on e.DepartmentId = d.DepartmentId

  • Thanks Karl Grambow

    But there are 15 columns so I have to write all 15 column names. Is there any way that we don't need to write all column names.

    Swapnil.

  • select d.DepartmentName, e.*

    from Department d

    join Employee e on e.DepartmentId = d.DepartmentId

Viewing 4 posts - 1 through 3 (of 3 total)

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