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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:32:36+00:00 2026-05-13T07:32:36+00:00

EDIT:That was fast. The reason why I have this is because the table is

  • 0

EDIT:That was fast. The reason why I have this is because the table is a pivot table between 2 tables one has “id” as primary key and the other “type” primary key

Hello.

I want the following:

Find only find “id” where “type” is 1 AND 2 AND 3

This is not working:

SELECT * FROM `table` WHERE `type` = 1 AND `type` = 2 AND `type` = 3;

The SELECT statment should only return one row (id = 1)

Table

id type
1  1
1  2
1  3

2  1
2  2

3  3
  • 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-13T07:32:37+00:00Added an answer on May 13, 2026 at 7:32 am

    If you only want to know the Id then add the keyword Distinct and just select the id,
    where there are records for the three different types …

      Select Distinct id 
      FROM `table` t
      WHERE  Exists (Select * From Table Where id = t.id and Type = '1')
         And Exists (Select * From Table Where id = t.id and Type = '2')
         And Exists (Select * From Table Where id = t.id and Type = '3')
    

    If you want to see the Id and the type then add the type to the select,

     Select Distinct id, Type 
      FROM `table` t
      WHERE  Exists (Select * From Table Where id = t.id and Type = '1')
         And Exists (Select * From Table Where id = t.id and Type = '2')
         And Exists (Select * From Table Where id = t.id and Type = '3')
    

    if you want to see every row that has that id, then leave out the distinct

      Select id, Type 
      FROM `table` t
      WHERE  Exists (Select * From Table Where id = t.id and Type = '1')
         And Exists (Select * From Table Where id = t.id and Type = '2')
         And Exists (Select * From Table Where id = t.id and Type = '3')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table, UserRewards that has 30+ million rows. In this row,
Edit : The bug that caused this problem has been fixed. The @version tag
I have the following tables (example) t1 (20.000 rows, 60 columns, primary key t1_id)
I've got a DLL written in C (that I can't edit) that has some
*edit: I understand that stackoverflow has banned all questions regarding using Microsoft's Visio. I'm
EDIT: I realized that this code compiles and works: #include <iostream> template<class Something> class
I have a table filled with tableviewcells that have an imageview as their highlight
George Marsaglia has written an excellent random number generator that is extremely fast, simple,
In my app I have a character that has feet and I want to
Edit : Note that, as Daniel and latkin noted in an answer and a

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.