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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:12:48+00:00 2026-06-04T20:12:48+00:00

I have a SQL Server database table ( DuplicateIds ) that contains the ID’s

  • 0

I have a SQL Server database table (DuplicateIds) that contains the ID’s of duplicate words from another table (Words). Here’s and example of the data in the table DuplicateIds:

        word_id  |  word
----------------------------------
        244      |  ape
        603      |  ape
       1873      |  ape
        372      |  banana
       3095      |  banana

…and so on. Often there are only two or three duplicates but there are cases with 10 or even more duplicates.

Now I want to use this table with duplicates to create a new table that connects the ID’s of the words that are the same. I guess the new table would look something like this:

        word_id  |  connected_id
----------------------------------
        244      |    603
        244      |   1873
        603      |    244
        603      |   1873
       1873      |    244
       1873      |    603
        372      |   3095
       3095      |    372

With this table I can look up a certain word using its ID and get the ID’s of all the words that are the same.

Now I wonder if I can write a (T)SQL statement that generates this new connection table for me, using the data from DuplicateIds?

  • 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-04T20:12:49+00:00Added an answer on June 4, 2026 at 8:12 pm

    This should do it:

    SELECT
       di.word_id
      ,di2.word_id  connected_id
     into NewTable
     from DuplicateIds di
      inner join DuplicateIds di2
       on di2.word = di.word
        and di2.word_id <> di.word_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL Server 2008 database with a table that contains a FILESTREAM
I have a sql server 2008R2 with a database that have table with thousands
Ok I have a table in my SQL Server database that stores comments. My
I have a DataGridView which is filling from Table in SQL Server Database. One
I have a junction table in my SQL Server 2005 database that consist of
I have a SQL Server 2008 database table that uses uniqueidentifier as a primary
We have a SQL Server database table that consists of user id, some numeric
I i have a SQL Server database table called tbl_faults . In that table
I have a simple table in my SQL Server database. This table contains two
I have a SQL Server database with a table that has a column that

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.