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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:24:33+00:00 2026-05-22T12:24:33+00:00

I have the following 3 tables table1 id name ———- 1 john 2 dave

  • 0

I have the following 3 tables

table1

id    name
----------
1     john
2     dave
3     eve

table2

table1_id    table3_id
----------------------
   1            2            
   1            3
   1            5
   2            2
   2            3
   2            4
   3            1
   3            5

table3

id    title
------------
1     blue
2     orange
3     green
4     yellow
5     black

I’m trying to select each table1.name where table3.title = (blue OR orange) AND (green OR black)

so that the output is

name
----
john
dave

This is my query so far that won’t get this job done:

SELECT table1.name 
FROM table1 
JOIN table2 ON table1.id = table2.table1_id
JOIN table3 t1 ON table2.table3_id = t1.id
JOIN table3 t2 ON t1.title = t2.title
WHERE t1.title IN ('blue', 'orange')
AND t2.title IN ('green', 'black')

Any suggestions would be really appreciated!

UPDATE
One more question 🙂

How to select each table1.name where table3.title = (‘green’ AND ‘orange’ AND ‘black’ AND ‘…’)

  • 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-22T12:24:34+00:00Added an answer on May 22, 2026 at 12:24 pm

    If I’m getting your question right, you’re close:

    SELECT table1.name
    FROM table1 
    JOIN table2 t1_link ON table1.id = t1_link.table1_id
    JOIN table3 t1_data ON t1_link.table3_id = t1_data.id AND t1_data.title in ('blue', 'orange')
    JOIN table2 t2_link ON table1.id = t2_link.table1_id
    JOIN table3 t2_data ON t2_link.table3_id = t2_data.id AND t2_data.title in ('green', 'black')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following two tables: Table1 ---------- ID Name 1 A 2 B
I have the following tables Pedal Brand:string Classification:string Model:string Variety Title:string name:string pedal_id:integer Example
I have following databases: test table1 fields: id, password, name, lastname test2 table2 fields:
I have two tables and the following query: table1 --------- table1Id(pk) fromdate, todate, name,
I have the following 3 tables Table1 ID | NAME ----------- 1 | X
I have two tables that have following rows: Table1 ID Name Number ===================== 1
I have 2 tables with the following fields. Table1 AA BB CC DD Table2
I have two tables with the following columns: table1: id, agent_name, ticket_id, category, date_logged
I have the following code: ListBox.DataSource = DataSet.Tables(table_name).Select(some_criteria = match) ListBox.DisplayMember = name The
I have the following tables in SQL Server 2005 ReceiptPoint: ID (PK), Name GasIndexLocation:

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.