Select query from 2 tables

Posted on 2014-08-11
Last Modified: 2014-08-12
I have two tables. One table is called Employees and one is called Teams.

In the Employee table I have the following columns (Name, StartDate, Position, TeamID)
In the Teams table I have the following columns (URL, Active, TeamID)

I want to select Name, StartDate, and Position from the Employee table
as well as
URL, and Active from the Teams table
Where the ID is the same

For example...
Employee record: Mike Smith | 1/1/1980 | Comptroller | 55
Teams record: | Yes | 55

would display this in the result:

Mike Smith 1/1/1980 Comptroller Yes

How do I do this?
Question by:mwmiller78
    LVL 14

    Accepted Solution


    You have to use Join

    select Name, StartDate, Position, URL, Active  from Employee 
    INNER JOIN Teams ON Employee .TeamID = Teams.TeamID

    Open in new window

    LVL 35

    Expert Comment

    by:David Todd
    LVL 47

    Expert Comment

    another SQL tutorial site:
    LVL 30

    Expert Comment

    Agree with Vikas Garg's comment as a direct answer. Other comments help in the learning process.

    If you need more info on INNER JOIN to join more tables see this article:
    INNER JOIN a Number of Tables

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
    Via a live example, show how to shrink a transaction log file down to a reasonable size.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now