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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:41:05+00:00 2026-06-01T00:41:05+00:00

Im having some trouble with joining two tables. This is what my two tables

  • 0

Im having some trouble with joining two tables. This is what my two tables look like:

Table 1

Customer_ID   CustomerName   Add. 
1000          John Smith
1001          Mike Coles
1002          Sam Carter

Table 2

Sensor_ID     Location      Temp    CustIDFK
1000          NY            70
1002          NY            70
1000          ...           ...
1001
1001
1002

Desired:

Sensor_ID     Location      Temp    CustIDFK
1000          NY            70      John Smith
1002          NY            70      Sam Carter
1000          ...           ...     John Smith
1001                                Mike Coles
1001
1002

I have made Customer_ID from table 1 my primary key, created custIDFK in table 2 and set that as my foreign key. I am really new to sql server so I am still having trouble with the whole relationship piece of it. My goal is to match one customer_ID with one Sensor_ID. The problem is that the table 2 does not have “unique IDs” since they repeat so I cant set that to my foreign key. I know I will have to do either an inner join or outer join, I just dont know how to link the sensor id with customer one. I was thinking of giving my sensor_ID a unique ID but the data that is being inserted into table 2 is coming from another program. Any suggestions?

  • 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-01T00:41:07+00:00Added an answer on June 1, 2026 at 12:41 am

    Based on your data, it looks like the value of Sensor_ID should instead exist in CustIDFK. I would then suggest making Sensor_ID an identity value within your sensor table, and make that value the primary key of this table.

    If you want to associate the two tables, you should be able to simply join on Customer_ID and CustIDFK once it has been properly populated with the value currently in Sensor_ID.

    SELECT
        t1.Customer_ID, t1.CustomerName, t2.Location, t2.Temp
    From
        Table1 t1 JOIN
        Table2 t2 ON t1.Customer_ID = t2.CustIDFK
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a new and am having some trouble with joining two tables. table1:
Having some trouble getting this query to work correctly. mysql_query(DELETE FROM `table` WHERE `id`
Having some trouble getting this to work... I basically want the report to look
Im having some trouble writing a getstring function, this is what I have so
I'm having some trouble getting log4net to work from ASP.NET 3.5. This is the
I having some trouble figuring this problem out where I have one button which
Having some trouble with this code. Trying to return a tuple of tuples (coordinates)
I´m having some trouble deciding in which way to go... I've got this application
I'm having some trouble with this code. I am trying to write a function
having some trouble trying to figure this out, complete novice when it come to

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.