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

  • Home
  • SEARCH
  • 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 7640591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:42:31+00:00 2026-05-31T08:42:31+00:00

I am trying to come up with a SQL query string to read information

  • 0

I am trying to come up with a SQL query string to read information from three tables, where they have overlapping column names:

Table: Task
Id
TaskDescription
...

Table: TaskAttempt
Id
TaskId
User
...

Table: TaskSubmission
Id
TaskAttemptId
Data
...

A task contains a description. Users can attempt to complete the task and they submit their results. Each task attempt can have multiple submissions.

When reviewing, I want to pull in all task submissions and display the description, user, and data; I also need to pull in all the Id fields so that I can update the rows upon review completion.

What would a SQL statement look like to capture this?

  • 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-31T08:42:32+00:00Added an answer on May 31, 2026 at 8:42 am

    To deal with column names that are the same in different tables, you have to prefix the columns with the table that you are requesting the data from. This is a VERY basic shell of what your query would look like. The JOIN statements need the corresponding columns, but you did not provide the schema on how they match up. However, this answers your basic question about columns with the same name.

    SELECT Task.Id, Task.TaskDescription, TaskAttempt.Id, TaskAttempt.User, 
        TaskSubmission.Id, TaskSubmission.Data
    FROM Task
       JOIN TaskAttempt
           ON Task.Id = TaskAttempt.TaskId
       JOIN TaskSubmission
           ON TaskAttempt.Id = TaskSubmission.TaskAttempId
    

    Prefixes simply give the SQL engine enough extra data to know how to handle ambiguities, and they also can provide much more expressive code to future readers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very weird problem while trying to pass and SQL query using
I'm trying to come up with an compiled query using Entity SQL and I'm
I am trying come up with a way to pull the tables out of
I've been trying to come up with a way to create a 3 column
I have a sql query that performs the type of select I'm after: select
I have a view defined in SQL server 2008 that joins 4 tables together.
I am trying to get a grip on the pivot query syntax. I have
As with most, I come from and RDMS world trying to get my head
I'm trying to rewrite a SQL query in LINQ to Entities. I'm using LINQPad
I am trying to do rather complex SQL query to produce a report. This

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.