<bdo id='OhGq2'></bdo><ul id='OhGq2'></ul>
  1. <legend id='OhGq2'><style id='OhGq2'><dir id='OhGq2'><q id='OhGq2'></q></dir></style></legend>
  2. <small id='OhGq2'></small><noframes id='OhGq2'>

    <tfoot id='OhGq2'></tfoot>

    <i id='OhGq2'><tr id='OhGq2'><dt id='OhGq2'><q id='OhGq2'><span id='OhGq2'><b id='OhGq2'><form id='OhGq2'><ins id='OhGq2'></ins><ul id='OhGq2'></ul><sub id='OhGq2'></sub></form><legend id='OhGq2'></legend><bdo id='OhGq2'><pre id='OhGq2'><center id='OhGq2'></center></pre></bdo></b><th id='OhGq2'></th></span></q></dt></tr></i><div id='OhGq2'><tfoot id='OhGq2'></tfoot><dl id='OhGq2'><fieldset id='OhGq2'></fieldset></dl></div>
    1. 选择案例时(选择)

      SELECT CASE WHEN THEN (SELECT)(选择案例时(选择))
        <tbody id='OYDtn'></tbody>

        1. <small id='OYDtn'></small><noframes id='OYDtn'>

          <legend id='OYDtn'><style id='OYDtn'><dir id='OYDtn'><q id='OYDtn'></q></dir></style></legend>

        2. <tfoot id='OYDtn'></tfoot>

            <i id='OYDtn'><tr id='OYDtn'><dt id='OYDtn'><q id='OYDtn'><span id='OYDtn'><b id='OYDtn'><form id='OYDtn'><ins id='OYDtn'></ins><ul id='OYDtn'></ul><sub id='OYDtn'></sub></form><legend id='OYDtn'></legend><bdo id='OYDtn'><pre id='OYDtn'><center id='OYDtn'></center></pre></bdo></b><th id='OYDtn'></th></span></q></dt></tr></i><div id='OYDtn'><tfoot id='OYDtn'></tfoot><dl id='OYDtn'><fieldset id='OYDtn'></fieldset></dl></div>
              <bdo id='OYDtn'></bdo><ul id='OYDtn'></ul>
              • 本文介绍了选择案例时(选择)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试根据产品类型为产品选择一组不同的结果.因此,如果我的产品应该是一本书,我希望它查找普通产品的 UPC 和艺术家,但这些细节无关紧要,而对于另一个产品,我想要一组完全不同的结果.

                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 normal product these details are however irrelevant and for another product I would want a completely different set of results.

                SELECT CASE Product.type_id
                    WHEN 10 THEN (
                        SELECT 
                        Product.product_id, 
                        Product.type_id, 
                        Product.product_name, 
                        Product.UPC,
                        Product_Type.type,
                        CONCAT_WS(' ' , first_name, middle_name, last_name ) AS artistC 
                        FROM Product, Product_Type, Product_ArtistAuthor 
                        WHERE Product.type_id = Product_Type.type_id 
                        AND Product.product_id = $pid
                        AND Product.artist_id = Product_ArtistAuthor.artist_id
                    )
                    ELSE (
                        SELECT 
                        Product.product_id, 
                        Product.type_id, 
                        Product.product_name,
                        Product_Type.type 
                        FROM Product, Product_Type 
                        WHERE Product.type_id = Product_Type.type_id 
                        AND Product.product_id = $pid
                    )
                END
                FROM Product 
                WHERE Product.product_id = $pid
                

                我不确定我哪里出错了

                推荐答案

                你可以试试 case 语句的其他格式

                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
                

                参见 http://msdn.microsoft.com/en-us/library/ms181765.aspx 了解更多信息.

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

                这篇关于选择案例时(选择)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Set the variable result, from query(设置变量结果,来自查询)
                What is dynamic SQL?(什么是动态 SQL?)
                Mysql - How to quit/exit from stored procedure(Mysql - 如何退出/退出存储过程)
                Does MySQL have time-based triggers?(MySQL 有基于时间的触发器吗?)
                is it possible to call a sql script from a stored procedure in another sql script?(是否可以从另一个 sql 脚本中的存储过程调用 sql 脚本?)
                Procedure to loop through comma separated string is not working(遍历逗号分隔字符串的过程不起作用)
              • <tfoot id='WGBwp'></tfoot>
                <legend id='WGBwp'><style id='WGBwp'><dir id='WGBwp'><q id='WGBwp'></q></dir></style></legend>
                  <bdo id='WGBwp'></bdo><ul id='WGBwp'></ul>

                    <small id='WGBwp'></small><noframes id='WGBwp'>

                      <i id='WGBwp'><tr id='WGBwp'><dt id='WGBwp'><q id='WGBwp'><span id='WGBwp'><b id='WGBwp'><form id='WGBwp'><ins id='WGBwp'></ins><ul id='WGBwp'></ul><sub id='WGBwp'></sub></form><legend id='WGBwp'></legend><bdo id='WGBwp'><pre id='WGBwp'><center id='WGBwp'></center></pre></bdo></b><th id='WGBwp'></th></span></q></dt></tr></i><div id='WGBwp'><tfoot id='WGBwp'></tfoot><dl id='WGBwp'><fieldset id='WGBwp'></fieldset></dl></div>
                        <tbody id='WGBwp'></tbody>