Link to home
Create AccountLog in
Avatar of Curtis Long
Curtis LongFlag for United States of America

asked on

Merge data from two sql tables

I have a sql database with two tables I am working with


Tote_RFID

Trash


In the trash table these is a column "RFID_Number" 


In the Tote_RFID table there is a colum RFID_Number that matches the number in the trash table.  The next column is RFID_Discription that has the identifier


If I create a view and add only the trash table and select all columns I get data I expect minus, of course, the data from the Tote_RFID data.  


If I add the table for the Tote_RFID all data goes away.


I need to add the column RFID Discription from Tote_RFID to my view.


I hope this makes sense.  

Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Can you provide some sample data from both tables and the expected results?
Avatar of Curtis Long

ASKER

This is waht comes from trash table:


User generated image


This is from Tote_RFID


User generated image

I would like a view that shows this:


User generated image



Can you post text based data so we can set up a test case?

Just enough rows from each table to show the requirements then the expected results from those rows?

Without that seems like a simple join:
select 
  t.ID,
  t.RFID_Number,
  r.RFID_Description,
  ...the other columns
from Tote_RFID r
join Trash t
on r.RFID_Number=t.RFID_Number

Open in new window

Trash select all

ID   Date_Time   RFID_Number   Bin_RFID   Tote_Full_Wt   Tote_Empty_Wt   Location_Code   Manual_Wt   Transfered   ShiftID   LineID   ReasonID

601   2022-10-10 19:24:29.653   13434   13435   1000.0   200.0   PEPPER01   0   1   NULL   NULL   NULL

602   2022-10-10 19:28:07.880   13434   13435   1000.0   200.0   PEPPER01   0   1   NULL   NULL   NULL

603   2022-10-10 20:26:06.870   13443   13435   338.0   86.0   PEPPER01   0   1   NULL   NULL   NULL

604   2022-10-10 20:30:38.800   13443   13435   383.0   97.0   PEPPER01   0   1   NULL   NULL   NULL

605   2022-10-10 20:38:48.470   13443   13435   332.0   92.0   PEPPER01   0   1   NULL   NULL   NULL

606   2022-10-10 20:44:14.857   13443   13435   250.0   94.0   PEPPER01   0   1   NULL   NULL   NULL

1601   2022-10-10 20:50:57.223   13443   13435   377.0   89.0   PEPPER01   0   1   NULL   NULL   NULL


Tote_RFID select all

ID   RFID_Number   RFID_Description   Location_Code   User_Name   NoWeighTote   NWToteGross   NwToteTare

16   13443   CHOCOLATEENROBERAREAWASTE   PEPPER01   NULL   NULL   NULL   NULL

17   13432   COOKIEPACKAGINGAREAWASTE   PEPPER01   NULL   NULL   NULL   NULL

18   13431   COOKIEPROCESSINGAREAWASTE   PEPPER01   NULL   NULL   NULL   NULL

19   13436   CRACKERPROCESSING10   PEPPER01   NULL   NULL   NULL   NULL

20   13442   CRACKERPROCESSING5   PEPPER01   NULL   NULL   NULL   NULL


ToteRFID design:


ID   int   Unchecked

RFID_Number   nvarchar(50)   Unchecked

RFID_Description   nvarchar(50)   Unchecked

Location_Code   nvarchar(10)   Checked

User_Name   nvarchar(50)   Checked

NoWeighTote   bit   Checked

NWToteGross   int   Checked

NwToteTare   int   Checked


Trash design:


ID   int   Unchecked

Date_Time   datetime   Checked

RFID_Number   nvarchar(50)   Unchecked

Bin_RFID   nvarchar(50)   Unchecked

Tote_Full_Wt   decimal(8, 1)   Unchecked

Tote_Empty_Wt   decimal(8, 1)   Unchecked

Location_Code   nvarchar(10)   Checked

Manual_Wt   bit   Checked

Transfered   bit   Unchecked

ShiftID   int   Checked

LineID   int   Checked

ReasonID   int   Checked


ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account

Thank you so much!!  That works perfectly!!