doramail05
asked on
Getting SQL Select parameter and apply into another select statement
i try to get the product_category from " SELECT product_category from sales_view where customerno = 12100"
and apply into "SELECT product_name from products where product _category = " product category from above.
im using c# ADO.NET.
and apply into "SELECT product_name from products where product _category = " product category from above.
im using c# ADO.NET.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you want to use join use alias:
select a.product_name
from products a
inner join sales_view b on a.product_category = b.product_category
where a.customerno = 12100
If SELECT product_category from sales_view where customerno = 12100 query is always returning only single result then you can use the query using "=" operator using the nested query else use "IN".
SELECT PRODUCT_NAME FROM PRODUCTS WHERE PRODUCT_CATEGORY LIKE (SELECT PRODUCT_CATEGORY FROM SALES_VIEW WHERE CUSTOMERNO=12100) ABC
ABC is just the name of inner (sub) query.
ABC is just the name of inner (sub) query.
Open in new window