I have a bit of a unique situation. I am loading a DropDownList (asp.net) from a SQL DB. Let me explain my scenario.
[Products] [DB2.dbo.Orders]
-Product_ID -Order_ID
-Product_Name -Order_Product_Name
-Product_Price -Order_Product_Price
-Order_QTY
[DROP DOWN] [PRICE_LABEL]* [OrderQTY] +ADD
ProdName1
ProdName2
ProdName3
[PRICE_LABEL]: *(gets pulled by Select Product_Price where Product_Name=DropDown.Selected)
After I add the info on the page it Inserts into the DB2.dbo.ORDERS table. Then I have another row Select that information back out for an edit Row. The issue is when I render the DropDown I need to select ALL of the Product Names BUT, I need the Product Name Stored in Orders to be the default value. I thought I could do something like this:
SELECT * FROM dbo.PRODUCTS WHERE PRODUCT_NAME =
(select
BHPropertyInfo.dbo.PURCHASE_ORDER_OFFICE_EQUIPMENT.PURCHASE_ORDER_OFFICE_EQUIPMENT FROM
BHPropertyInfo.dbo.PURCHASE_ORDER_OFFICE_EQUIPMENT
WHERE
BHPropertyInfo.dbo.PURCHASE_ORDER_OFFICE_EQUIPMENT.PURCHASE_ORDER_OFFICE_KEY = 157)
UNION
SELECT * FROM dbo.PRODUCTS WHERE PRODUCT_NAME !=
(select
BHPropertyInfo.dbo.PURCHASE_ORDER_OFFICE_EQUIPMENT.PURCHASE_ORDER_OFFICE_EQUIPMENT FROM
BHPropertyInfo.dbo.PURCHASE_ORDER_OFFICE_EQUIPMENT
WHERE
BHPropertyInfo.dbo.PURCHASE_ORDER_OFFICE_EQUIPMENT.PURCHASE_ORDER_OFFICE_KEY = 157)
as to avoid duplicates and keep it Ordered correctly...unfortunately this will always return the same results as SELECT * FROM PRODUCTS... which technically is what i need...i just want the first row to correspond with ORDER_EQUIPMENT_NAME...
Please advise I know there should be a way to do this in my SQL statement.