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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:13:58+00:00 2026-05-28T00:13:58+00:00

I have a sql table similar to the one below. And I want to

  • 0

I have a sql table similar to the one below. And I want to bring back unique results where tag_id matches multiple items.
So if I want to find each image_id that has the tag_id = 106 and 73 I would like it to bring back image_id 12345714 and 12345712.

I’ve tried doing

SELECT * 
FROM tag_relationship
WHERE tag_id
IN ( 106, 73 ) 

But this brings back

        id  image_id    tag_id
        61  12345706    73
        70  12345712    73
        72  12345712    106
        76  12345714    73
        77  12345714    106

I’ve also experimented with GROUP BY, but that doesn’t seem to be quite right.

Sample of full table:
image_id can have the same number in different rows, but will have a different tag_id.

       id   image_id    tag_id
        1   12345679    63
        2   12345679    83
        3   12345680    74
        4   12345680    108
        5   12345680    75
        6   12345683    103
        7   12345682    87
        8   12345682    105
        9   12345682    74
        10  12345682    81
        11  12345683    79
        12  12345683    109
        13  12345689    111
        14  12345689    69
        15  12345690    104
        16  12345687    110
        17  12345687    69
        18  12345687    91
        19  12345687    93
        20  12345687    63
        21  12345692    69
        22  12345692    104
        23  12345692    80
        24  12345692    76
        25  12345693    74
        26  12345693    99
        27  12345693    96
        28  12345693    94
        29  12345691    63
        30  12345691    69
        31  12345697    92
        32  12345697    76
        33  12345698    74
        34  12345699    97
        35  12345698    94
        36  12345699    98
        37  12345698    81
        38  12345699    105
        39  12345697    91
        40  12345694    100
        41  12345694    101
        42  12345694    94
        43  12345694    74
        44  12345696    78
        45  12345696    95
        46  12345696    112
        47  12345701    113
        48  12345701    114
        49  12345700    94
        50  12345700    91
        51  12345700    90
        52  12345702    87
        53  12345702    115
        54  12345702    80
        55  12345702    74
        56  12345704    78
        57  12345705    83
        58  12345705    84
        59  12345704    63
        60  12345705    104
        61  12345706    73
        62  12345706    64
        63  12345706    86
        64  12345706    88
        65  12345706    89
        66  12345713    80
        67  12345713    115
        68  12345713    81
        69  12345717    63
        70  12345712    73
        71  12345717    64
        72  12345712    106
        73  12345717    79
        74  12345712    74
        75  12345709    76
        76  12345714    73
        77  12345714    106
        78  12345715    68
        79  12345716    116
        80  12345715    69
        81  12345716    71
  • 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-28T00:13:59+00:00Added an answer on May 28, 2026 at 12:13 am
    SELECT   image_id 
    FROM     tag_relationship
    WHERE    tag_id IN ( 106, 73 )
    GROUP BY image_id
    HAVING   COUNT(*) = 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQL table defined as below: CREATE TABLE [TestComposite] ( ID int,
I have an SQL table like this : sales(product,timestamp) I want to display a
I have an issue similar to this one: SQL Server 2008: ODBC connection problems
I have a table like the one below. It is a record of daily
I have a SQL table with news stories and Unix timestamps. I'd like to
I have a SQL table which has a number of fields ID | Value
I have a SQL table like so: Update: I'm changing the example table as
I have a sql table which have the following data, Id City Country ---
I have an SQL table written in MSSQL: create table [action] ( action_id bigint
I have a SQL table where in each row I store the country and

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.