Let\'s say I have the following table:
CREATE TABLE orders ( Order_ID int, Product_ID int, PRIMARY KEY(Order_ID,Product_ID) ); INSERT INTO orders VA
If I've understood you correctly:
Select ID From table_name where P_ID = 2