Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 576123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:00:50+00:00 2026-05-13T14:00:50+00:00

I have 3 tabels in my SQL Server database with the following info: tabel:

  • 0

I have 3 tabels in my SQL Server database with the following info:

tabel:      TeacherInfo
columns:     tID,     tName,     tAge,     tLocationId
values       1         Abel       53          1
             2         Bob        23          2
             3         Apaul      24          2

tabel:      LocationInfo
columns:    lId,    lDesc
values:     1     Street A
            2     Street B

tabel:      CourseInfo
columns:    cId,    cName,   masterTeacherId,   assistTeacherId
values:     1       Maths          1                    2
            2       English      1                    3

What I need is a SQL query script that can return the following values,

couseName,  masterName, masterAge,  masterLocation, assistName, assistAge,  assistLocation

Maths       Abel        53      Street A    Bob       23        Street B
English     Abel        53      Street A    Apaul       24      Street B

So how to write the SQL script? Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:00:50+00:00Added an answer on May 13, 2026 at 2:00 pm

    You need to alais the tables differentially in the FROM clause:

    SELECT CourseInfo.cName as courseName, Mst.tName as masterName, 
            Mst.tAge as masterAge,  MstLoc.lDesc as masterLocation, 
            Ass.tName as assistName, Ass.tAge as assistAge,  AssLoc.lDesc as 
    assistLocation 
    
    FROM CourseInfo 
        join TeacherInfo Mst on masterTeacherId = Mst.tID 
        join LocationInfo MstLoc on Mst.tLocationId = MstLoc.lId 
        join TeacherInfo Ass on assistTeacherId = Ass.tID 
        join LocationInfo AssLoc on Ass.tLocationId = AssLoc.lId
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tabel in an Sql Server 2005 database. I have the following
I have a SQL Server 2000 database with around a couple of hundred tables.
I have designed database tables (normalised, on an MS SQL server) and created a
I have two tables in a SQL Server 2008 database in my company. The
I have to write a component that re-creates SQL Server tables (structure and data)
I have a couple of tables in a SQL 2008 server that I need
I have a linq to sql database. Very simplified we have 3 tables, Projects
I have an SQL database with multiple tables, and I am working on creating
I have some Crystal Reports connecting to a Sql Server db that I would
I am upscaling an access 2003 database to SQL Server Express 2008. The tables

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.