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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:21:02+00:00 2026-06-08T04:21:02+00:00

RDBMS SQL Server, T-SQL Consider a table that links information from two different tables:

  • 0

RDBMS SQL Server, T-SQL

Consider a table that links information from two different tables: Articles and Categories. This table contains for each Article one or several entries containing the ID of the Categories the Article belongs to. Therefore, a

SELECT * FROM TABLE WHERE ARTICLEID = X 

returns 1 to n results.

I am looking to build a query which allows me to compare Articles that have the exact same combination of Categories. I’ve been trying with INTERSECT, but that does not return any rows. An example:

ARTICLEID  CATEGORYID

    1  1
    1  2
    1  4
    2  1
    2  4
    3  1
    3  2
    3  4
    4  2
    4  4
    5  1
    5  2
    5  4

The query for ARTICLEID = 1 should return 3 and 5, for ARTICLEID = 3 should return 1 and 5, et cetera.

  • 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-08T04:21:03+00:00Added an answer on June 8, 2026 at 4:21 am

    EDITed: This should work

    with temp as
    (
        select a.*, b.articleid as bart, 1 as cnt from tableName a left join
        tableName b on a.CATEGORYID=b.CATEGORYID where a.articleid=XXX
    )
    select bart from temp where bart<>articleid group by bart having sum(cnt) =
    (select count(*) from tableName where articleid=XXX)
    

    Just run this exact query, changing only the XXX to whatever articleID that you need to match. It should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We use SQL server 2008 as our RDBMS and we have a database that
I have two servers on my network, one for RDBMS (Sql Server 2005) and
We are using SQL Server 2005, but this question can be for any RDBMS
I've developed a very simple ASP.NET (jQuery) application. The RDBMS is MS Sql Server
when we say rdbms that means it may be oracle, my sql, ms access
Checking few RDBMS I find that things like SELECT COUNT (a), SUM (b) FROM
Prerequisite: There is client/server application written in Delphi32. The RDBMS is SQL Server 2005.
As a C# developer that uses MS SQL Server heavily I'd prefer to use
i'm trying to migrate some data from two tables in an OLD database, to
Which Freeware GUI tool for Firebird RDBMS closestly resembles MS SQL Server 2000 Management

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.