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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:54:34+00:00 2026-06-13T05:54:34+00:00

I have 3 tables in sqlite, the first one is about an entity I

  • 0

I have 3 tables in sqlite, the first one is about an entity I call bar:

bar
    *id
    -name

and the other one keeps a relationship between two bars, I call this relationship foo:

foo
    *id
    -bar_one (fk->bar)
    -bar_two (fk->bar)
    -baz (fk->baz)

baz holds an attribute that qualifies the KIND relationship that foo represents:

baz
    *id
    -description

I need to show a query of foo that substitutes the foreign keys with the values of bar an baz, something like:

id    bar_one    bar_two    baz
1     bar1       bar2       siblings
2     bar2       bar3       acquaintances
3     bar3       bar4       enemies

I’m not a specialist in DBs as you can see, I tried with a join and it works with foo and baz.

SELECT foo.id, baz.description FROM foo, baz WHERE foo.baz = baz.id;

But to show the two members of bar is difficult for me in this way. Some advice?

  • 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-13T05:54:34+00:00Added an answer on June 13, 2026 at 5:54 am

    Assuming that columns of table foo: bar_one (fk->bar), bar_two (fk->bar), baz are non-null columns, you can use INNER JOIN to combine both tables, but if they are nullable, use LEFT JOIN instead.

    SELECT  a.ID,
            b.name as bar_one,
            c.name AS bar_two,
            d.description
    FROM    foo a
            INNER JOIN bar b
                ON a.bar_one = b.id
            INNER JOIN bar c
                ON a.bar_two = c.id
            INNER JOIN baz d
                ON a.baz = c.id
    

    basically, INNER JOIN only displays the rows that a record has atleast one match on every table define, while LEFT JOIN displays all rows define on the left hand side whether there is match or none.

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

Sidebar

Related Questions

I have two tables. First one: create table history ( id integer primary key,
I have two tables in a SQLite DB, and both have the following fields:
C# (.NET 3.5) I have an SQLite database with two tables - employees (the
I have 4 tables in my SQLite database. One with questions, one with answers
I have a drill down tableview that is using sqlite. The first one is
In this example we have 3 related tables on a SQLite database: CREATE TABLE
My application has multiple SQLite tables(around 20 with different fields). This I have created
I have an SQLite database. I created the tables and filled them with a
So this is what I have, I have a SQLite database with 3 tables:
I have one table with almost 2 million records on my SQLite database, some

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.