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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:50:34+00:00 2026-06-15T15:50:34+00:00

I have two tables Table_1 id|subject_code|subject_id 1|Test1 |1 2|Test2 |2 3|Test3 |3 Table2 id|subject_id|grade|status

  • 0

I have two tables

Table_1
id|subject_code|subject_id
 1|Test1       |1
 2|Test2       |2
 3|Test3       |3

Table2
id|subject_id|grade|status
 1|1         |5.00 |Fail
 2|3         |2.25 |Pass

Now, I want to create a query that will return the following,

Table3
subject_code|grade|status
Test1       |5.00 |Fail
Test2       |NULL |NULL
Test3       |2.25 |Pass

I have read about combining left join and union all but I am lost on how to do that.
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-06-15T15:50:35+00:00Added an answer on June 15, 2026 at 3:50 pm

    Try a left join, like this::

    Select 
    DISTINCT(table1.subject_code), 
    grade, 
    status
    
    from table1 
    LEFT join table2 on (table1.subject_id=table2.subject_id)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have two tables table_1 ID Name Status 1 John 2 Peter
I have two tables as defined below: EMAILS ID SUBJECT BODY 1 Test1 blah
I have two tables Table 1: ref status abc 1 abc 1 abc 2
Dear stackoverflow experts, I have two tables table1<-read.table(table1.txt,header=TRUE) table2<-read.table(table2.txt,header=TRUE) I want to select from
I have two Tables: Table 1: Questions : QuestionId NUMERIC Title TEXT Test Data
I have two tables: table a ida valuea 1 a 2 b 3 c
I have two tables one with ID and NAME table 1 ID | NAME
I have two tables Table A type_uid, allowed_type_uid 9,1 9,2 9,4 1,1 1,2 24,1
I have two tables. Table 1. ======== id post -------- Table 2. ======== id
So I have two tables. Table 1 is named 'appointment' with the following fields:

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.