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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:28:43+00:00 2026-05-27T20:28:43+00:00

i have 3 tables crossarticle_article — Where article details are stored. crossarticle_category — Where

  • 0

i have 3 tables

  • crossarticle_article — Where article details are stored.
  • crossarticle_category — Where category details are stored.
  • crossarticle_articletocategory — Where article and category mappings are stored.. (this is because an article could exist in more than one category)
  • now i want to get the article based on the joins of all the three tables, but the problem is if i do that, i would get the repeated article title, as same article could be in more than one category, so no use of group by too. i need the crossarticle_category join because the category name exists in that table. and even if i skip that table, still crossarticle_articletocategory has the mapping for category and article. so still i would get repeated article title, can anyone suggest me some query so that i do not get repeated article titles.

    ****************************UPDATED QUESTION*************************
    

    http://www.prosoundnetwork.com/uploadedImages/ProAudioReview/Forum/PAR_Forum/Sample2/sqlquery.png

    you can right click and open in new window, to see the proper view, in the resultset you can see the titles are repeated.

    • 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-27T20:28:44+00:00Added an answer on May 27, 2026 at 8:28 pm

      Something like this will work:

        SELECT TOP 5 CA.Id AS ArticleID, CA.Title as ArticleTitle,
           stuff( (SELECT ', '+CC.Name
                   FROM  CrossArticle_ArticleToCategory A2C 
                   INNER JOIN CrossArticle_Category CC ON A2C.CategoryId = CC.Id
                   WHERE A2C.ArticleId = CA.Id
                   ORDER BY CC.Name
                   FOR XML PATH ('')
                  ), 1, 2, '') as Categories
        FROM CrossArticle_Article CA
      

      This will give you one row per article with a comma list of categories.
      It will look like this (I tested so it is correct):

      ArticleID   Article Title              Categories 
      5685        AlkjTechv                  Hardware
      5684        Show Report...             Gear, News
      5683        Radi-something introduces  Gear, News
      

      I only have 3 answers because you only gave example data for 3 results.

      As a side note: this is much faster than a custom aggregate.


      If what the categories are does not matter than a select like this will give you all the titles:

        SELECT TOP 5 CA.Id AS ArticleID, CA.Title as ArticleTitle,
        FROM CrossArticle_Article CA
      
      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report

    Sidebar

    Related Questions

    I have tables like this: tblUsers int UserID string UserName tblUsersInRoles int UserID int
    I have three tables: page, attachment, page-attachment I have data like this: page ID
    Hi i have tables like this : table entry : id | total_comments _____________________
    I have tables & data like this: venues table contains : id +----+---------+ |
    I have tables as posted in this question . •Measurements (MeasureID, Time, Distance, Value)
    I have tables (for simplicity sake) as outlined below: Category -------------------- CategoryId (0 for
    I have tables like this fake ones: data: id type month value 1 1
    I have tables like this License ------------ Id LicenseName DriversLicense ------------- Id LicenseId DriverId
    I have tables like this: Table1 Table2 name1 | link_id name2 | link_id text
    I have tables A and B and A_has_B where have this fields: A: id,

    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.