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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:00:40+00:00 2026-05-23T10:00:40+00:00

I have 4 tables, which are linked together with a foreign key from another,

  • 0

I have 4 tables, which are linked together with a foreign key from another, eg Table 2 has fk_table1, Table 3 has fk_table2, Table 4 has fk_table3.

The first 3 tables in this chain all have corresponding data for each entry. However, Table 4 contain optional data, therefore, there may not be a corresponding entry for a field in say Table 3.

But I want those data from Table 4 too. This is currently what I have, but doesn’t work.

SELECT *
        FROM T1, T2, T3 LEFT JOIN T4
        WHERE T1.t1 = T2.t1
        AND T2.t2 = T3.t2
        AND T3.t3 = T4.t3
  • 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-23T10:00:40+00:00Added an answer on May 23, 2026 at 10:00 am

    If only T4 is optional, use LEFT JOIN only on that table:

    SELECT *
    FROM T1
    JOIN T2 ON T1.t1 = T2.t1
    JOIN T3 ON T2.t2 = T3.t2
    LEFT JOIN T4 ON T3.t3 = T4.t3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following situation. A main table and many other tables linked together with
I have two tables linked together through the 3rd table threads: id, name tags:
i have two mysql tables which are linked together and i need to show
I have many tables in my database which are interrelated. I have a table
We have an Access DB which has a set of local tables and input
I have a mysql database which has grown to over 200 tables in it.
I have a DataSet which contains two tables, Publication and Owner, which are linked
I have a two tables which are linked by a one-to-many relationship. Now I
In SQL, I have a 1:1 relationship defined between 2 tables which are linked
I have a database for a forum-like website. It has a 'users' table, which

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.