SELECT CASE WHEN THEN (SELECT)

后端 未结 4 2190
孤街浪徒
孤街浪徒 2020-12-18 00:03

I am trying to select a different set of results for a product depending on a product type. So if my product should be a book I want it to look up the UPC and Artist for a n

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-18 00:51

    You Could try the other format for the case statement

    CASE WHEN Product.type_id = 10
    THEN
    (
      Select Statement
    )
    ELSE
    (
      Other select statement
    
    )  
    END
    FROM Product 
    WHERE Product.product_id = $pid
    

    See http://msdn.microsoft.com/en-us/library/ms181765.aspx for more information.

提交回复
热议问题