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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:25:21+00:00 2026-05-19T00:25:21+00:00

I have a database with three tables, a household table, an adults table and

  • 0

I have a database with three tables, a household table, an adults table and a users table. The Household table contains two foreign keys, iAdult1ID and iAdult2ID. The Users table has a iUserID primary key and the Adult table has a corresponding iUserID foreign key. One of the columns in the Users table is strUsername, an e-mail address.

I am trying to write a query that will allow me to search for an e-mail address for either adult that has a relation to the household. So I have two questions, assuming that all the values are not null, how can I do this?

And two, in reality, iAdult2ID can be null, is it still possible to write a query to do this?

Thanks for your help. Let me know if you need any more information.

  • 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-19T00:25:22+00:00Added an answer on May 19, 2026 at 12:25 am

    Yes, you just left join to the same table twice:

    select u1.strUsername, u2.strUsername
    FROM Household h
    LEFT JOIN Adult a1 on a1.ID = h.iAdult1ID
    LEFT JOIN Users u1 on u1.ID = a1.iUserID
    LEFT JOIN Adult a2 on a2.ID = h.iAdult2ID
    LEFT JOIN Users u2 ON u2.ID = a2.iUserID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three database tables with foreign keys to each other, and I want
I have three database tables: users emails invitations Emails are linked to users by
In my database I have three tables: Users: UserID (Auto Numbering), UserName, UserPassword and
I have three mysql table from same database Db1. Three tables have following columns.
I have a database which has three tables: A, B, and C. I want
So... assuming i have a database with three tables: Table clients Table data and
I have a SQL Server 2008 database. This database has three tables: Person -
I have three tables in my sample database: Users ID Username Password Roles ID
I have three database tables: users , user_profiles and friends : users id username
I have a database with three tables set up like this: Users : username,

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.