or use unpivot
SELECT m.orderid,n.product_id,m.quantity
FROM
(
SELECT orderid, product,quantity
FROM table1
UNPIVOT (quantity FOR product IN (product1,product2,product3,product4))u
)m
INNER JOIN product n
on n.product = m.product
------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/