Hello All,
I am semi-new to SQL query programming.
I have two tables that have fields as follows:
tblManEntry:
-Stock_Num
-Description
-QTY
-Stock_PN
tblInStock
-Stock_Num
-Description
-QTY
-PN1
-PN2
-PN3
What I have so far is I have 2 datagrids that I can search both tables separately and it return results. That works great.
But I would like it to display on one datagrid as follows.
I would like to make the query merge the data where it displays all the Stock_Nums in one column, Description, QTY, etc.
Then all the Partnumbers I just want them in one column as well. i have this working on the second datagrid by doing something like
I have tried Cross Join, Full Outer Join, etc and that all seem to just add the info from the tables to each other. Like if a PN in table 1 was 1234 and a PN in table 2 was 5678 then it'd merge them and it'd be 12345678 instead of two separate records.
This is what I currently have on two test tables
That just shows everything from each database all merged together.
Any ideas?
I am semi-new to SQL query programming.
I have two tables that have fields as follows:
tblManEntry:
-Stock_Num
-Description
-QTY
-Stock_PN
tblInStock
-Stock_Num
-Description
-QTY
-PN1
-PN2
-PN3
What I have so far is I have 2 datagrids that I can search both tables separately and it return results. That works great.
But I would like it to display on one datagrid as follows.
I would like to make the query merge the data where it displays all the Stock_Nums in one column, Description, QTY, etc.
Then all the Partnumbers I just want them in one column as well. i have this working on the second datagrid by doing something like
Code:
PN1 + ' ' + PN2 + ' ' + PN3 AS PN
I have tried Cross Join, Full Outer Join, etc and that all seem to just add the info from the tables to each other. Like if a PN in table 1 was 1234 and a PN in table 2 was 5678 then it'd merge them and it'd be 12345678 instead of two separate records.
This is what I currently have on two test tables
Code:
SELECT Test1.Stock_Num + '' + Test2.Stock_Num AS Stock_Num, Test1.Description + '' + Test2.Description AS Description, Test1.QTY + '' + Test2.QTY AS QTY,
Test1.Stock_PN + '' + Test2.Stock_PN AS Stock_PN
FROM Test2 CROSS JOIN
Test1
That just shows everything from each database all merged together.
Any ideas?