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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:53:58+00:00 2026-06-12T04:53:58+00:00

I have three separate queries that I’d like to combine into a single query

  • 0

I have three separate queries that I’d like to combine into a single query if possible. The intent is to find users that exist in any two of the three tables. They must exist AT LEAST two of the three tables.

user (user table)
user_job_ft_job (full time job)
user_job_own_venture (startup/own venture)
user_job_not_looking (not seeking employment)

-- not seeking and full time
SELECT * from user_job_not_looking ujnl, user_job_ft_job uj, [user] u  
WHERE 1=1
AND ujnl.user_id = u.user_id
AND uj.user_id = u.user_id    

-- own venture and full time   
SELECT * from user_job_own_venture ujov, user_job_ft_job uj, [user] u   
WHERE 1=1
AND ujov.user_id = u.user_id
AND uj.user_id = u.user_id 

-- own venture and not looking
SELECT * from user_job_own_venture ujov, user_job_not_looking ujnl, [user] u   
WHERE 1=1
AND ujov.user_id = u.user_id
AND ujnl.user_id = u.user_id   

I’d like to somehow combine these queries into one larger query so that I can an easier time writing dynamic code to handle this business case.

The structure of the tables shouldn’t matter, other than knowing they all have a foreign key called user_id which is the primary key of the [user] table.

  • 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-12T04:53:59+00:00Added an answer on June 12, 2026 at 4:53 am

    Left outer joins will cause the query to attempt to join on a table, but not require that child-table to have a matching record. If it doesn’t have a matching record, the fields from that table would be null. This query should do what you need.

    select * from [user] u
    left outer join user_job_not_looking as ujnl on ujnl.user_id=u.user_id
    left outer join user_job_own_venture as ujov on ujov.user_id=u.user_id
    left outer join user_job_ft_job as uj on uj.user_id=user_id
    where 
    (ujnl.user_id is not null and ujov.user_id is not null) or
    (ujnl.user_id is not null and uj.user_id is not null) or
    (ujov.user_id is not null and uj.user_id is not null)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have three separate color schemes that are used on various pages in
I have a .aspx page that loads three separate .ascx controls to represent adding,
I have the simplest code that I want to separate in three files: Header
Using MySQL, I have a number of queries that look like: SELECT * FROM
I have three separate table variables in my Function, 1 of them is not
I have three separate applications A, B and C. All of them use service
I have a Util package with source files in three seperate directories, defined like
I have a web application. It is separated into three sections, each with its
I have a rule, that gets up to three parts, separated by a /
Does anyone know if it is possible to write a query that can produce

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.