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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:41:33+00:00 2026-05-31T01:41:33+00:00

I have 2 tables that I need to join and select the unique rows

  • 0

I have 2 tables that I need to join and select the unique rows from. Here is a sample of my data: (there are more columns)

tbl1:
MB# MBName  PCCNo_PRI   Primary_IP       PCCNo_SEC          Secondary_IP    ID
100  name    0               10.1.9.10       30              10.1.9.10       1 
103  name3   17              10.1.9.27       47              10.1.9.67       4
403  name13  17              10.1.9.27       47              10.1.9.67       14

tbl2:

RTU PCC#_PRI    PCC#_SEC    STATION ADDRESS
15  0           30          6
52  12          42          1
53* 17          47          1
54  18          48          1
63  9           39          2
69* 17          47          2

I need to join the two tables and get the unique RTU(s) in tbl2 for a given MB# in tbl1.
Query =

SELECT t1.MB#,t2.RTU,t2.[Device Manufacturer],t2.PCC#_PRI,t2.PCC#_SEC,t2.[STATION ADDRESS] 
INTO C300_RTU_MASTERBLK_Map
FROM mbm_PCDIMasterBlk_tbl as t1, dbo.WOA_PCC_Conn_tbl as t2
WHERE t1.PCCNo_PRI = t2.PCC#_PRI

I am getting duplicate rows for tbl2 53 and 69 (* above). 53 ends up with 2 entries; one to 103 and one 403 (69 gets same). How can I query this for unique RTU(s) to MB#?

  • 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-31T01:41:34+00:00Added an answer on May 31, 2026 at 1:41 am

    The duplicate rows appears because you join on “17” which gives 2 rows on each side

    Then, as it stands, you can’t with that SELECT list.
    How do you decide which t1.MB# you want for the t2 columns?

    There is no secondary JOIN column that I can see.
    So the best you can get is use MAX (or MIN) to pick either 403 or 103.

    SELECT
       MAX(t1.MB#) AS MB#,
       t2.RTU,t2.[Device Manufacturer],t2.PCC#_PRI,t2.PCC#_SEC,t2.[STATION ADDRESS] 
    INTO C300_RTU_MASTERBLK_Map
    FROM 
       dbombm_PCDIMasterBlk_tbl as t1
       JOIN
       dbo.WOA_PCC_Conn_tbl as t2 ON t1.PCCNo_PRI = t2.PCC#_PRI
    GROUP BY
       t2.RTU,t2.[Device Manufacturer],t2.PCC#_PRI,t2.PCC#_SEC,t2.[STATION ADDRESS] 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables that I need to join... I want to join table1
I have 2 tables in a DB with very similar schemas that need to
I have a few huge tables on a production SQL 2005 DB that need
I have a couple of tables in a SQL 2008 server that I need
I have a database two tables and a linking table that I need a
I have a table of data that I need to dynamically add a column
I have table to test score data that I need to pivot and I
I have a table that contains maybe 10k to 100k rows and I need
I am making a cookie based favorite system and need to join data from
I have a mysql problem. I have two tables like this that I need

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.