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 8015237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:11:57+00:00 2026-06-04T20:11:57+00:00

I am at the task of joining 3 tables: Task, Unit, and Building. The

  • 0

I am at the task of joining 3 tables:
Task, Unit, and Building.

The task table has a column for a unit and a column for a building.
Any single task is assigned to only a building OR a unit, never both.
Thus one column in every record is always null. There are 6100 records in the task table.

when I use this JOIN:

select * from task t
join building b on b.id = t.building_id;

I get 628 rows. This is the correct total of building tasks.

When I use this JOIN

select * from active_task at
inner join unit_template ut on ut.id = at.unit_template_id

I get 5472 rows. This is the correct number of unit tasks.
If I add them up 5472+628 =6100 this is the correct # of rows in the task table.

When I run this Query:

select * from task t
inner join unit ut on ut.id = t.unit_id
inner join building bt on bt.id = t.building_id

I get zero rows. I need my query to retrieve 6100 rows.
Any help would be appreciated.

basic ER

  • 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-06-04T20:11:59+00:00Added an answer on June 4, 2026 at 8:11 pm

    Try a left join:

    select * from task t
    left join unit ut on ut.id = t.unit_id
    left join building bt on bt.id = t.building_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Each task has a reference to the goal it is assigned to. When I
I have two tables one to store a task and one to evaluate the
To filter a table output of selected entries from a single table i would
Task: Write timestamps into MS SQL database table every second. Solutions: External application which
I am aware of how unhanded exceptions are processed when using Task s, only
TASK: I'm building a set of x86 assembly reverse engineering challenges, of which I
I was recently assigned a task of creating an auction system. During my work,
Task Manager says that IE is using over 500MB of private working set. Both
Task : Print numbers from 1 to 1000 without using any loop or conditional
The task is to take a list of tables which is changeable. Write a

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.