JOIN
is the correct approach:
Joins (SQL Server) - SQL Server | Microsoft Learn[
^]
You haven't explained what you have tried, nor what the problem is. At a guess, try:
SELECT
C.Conversion_Id,
C.Item_Code1,
I1.Item_Name As Item_Name1,
C.Qty1,
C.Item_Code2,
I2.Item_Name As Item_Name2,
C.Qty2
FROM
tbl_Conversion As C
INNER JOIN tbl_Item As I1 ON I1.Item_Code = C.Item_Code1
INNER JOIN tbl_Item As I2 ON I2.Item_Code = C.Item_Code2
;
If the columns can contain
Null
, or your foreign key relationship is not set up properly, you may need to use
LEFT JOIN
instead of
INNER JOIN
.