select * from ...是什么意思,其中1 = sql中的条件

时间:2018-09-12 15:51:33

标签: sql sql-server

我在sql过程中看到过:select * from table 1=1

SELECT DISTINCT b.book_number   AS book_number, 
                b.book_title    AS b.nook_title, 
                o.order_summary AS order_summary, 
                otm.total_amt 
FROM   books b(nolock) 
       INNER JOIN books_detail bd (nolock) 
               ON b.b_id = bd.b_id 
       INNER JOIN order o(nolock) 
               ON o.author_id = b.author_id 
       INNER JOIN order_master otm(nolock) 
               ON otm.order_number = otm.order_number 
WHERE  b.status = 'AVAILABLE' 
       AND ( otm.cnt > 4 
              OR otm.total > 150 
              OR 1 = ( CASE 
                         WHEN @order = 'Any' THEN 0 
                         WHEN @order = 'devotional' THEN 1 
                         WHEN @order = 'investigation' THEN 1 
                         ELSE 0 
                       END ) ) 

我的问题是

的用途是什么
OR 1 = ( CASE 
                     WHEN @order = 'Any' THEN 0 
                     WHEN @order = 'devotional' THEN 1 
                     WHEN @order = 'investigation' THEN 1 
                     ELSE 0 
                   END ) ) 

1 个答案:

答案 0 :(得分:3)

如果遵循逻辑流程,您将看到 stacked_df.plot(kind='bar', stacked=True, x="CONTEXT") 表达式的结果是case1,并且0子句正在检查如果返回where

在这种特定情况下,表达式等同于:

1