zoukankan      html  css  js  c++  java
  • 记录一个SQL语句 case select 1

    select Code, CodeName, CodeAlias, ComCode, OtherSign
      from ldcode
     where codetype = 'edorapptype'
       and code <> (case
             when (select 1
                     from lccont b
                    where b.contno = 'W86190001290019'
                      and b.trdingchannel like 'ZFB%') = 1 then
              '-9'
             else
              '9'
           end)
       and othersign = '1'
     order by length(code), code asc
    

      去掉(case when)

     select Code, CodeName, CodeAlias, ComCode, OtherSign
      from ldcode
     where codetype = 'edorapptype'
       and code <> '-9' and othersign = '1'
    

      分析case when  1= 1 then '-9' else '9' end

    (case
             when (select 1
                     from lccont b
                    where b.contno = 'W86190001290019'
                      and b.trdingchannel like 'ZFB%') = 1 then
              '-9'
             else
              '9'
           end)
    

      分析 select 1

    select 1  from lccont b
                    where b.contno = 'W86190001290019'
                      and b.trdingchannel like 'ZFB%'
    

      select * ,select 某字段,

    可以用来查询表中是否有符合条件的记录(比如select 1 from seckill where id = 1001;),select 1一般用来当作条件使用,比如exists( select 1 from 表名)等。select 1的效率比select 列名select*快,因为不用查字典表。

  • 相关阅读:
    python框架之Flask(4)-上下文管理
    python框架之Flask(3)-Blueprint(蓝图)
    python框架之Flask(2)-路由和视图&Session
    python框架之Flask(1)-Flask初使用
    python中使用redis
    python之以字符串形式导入模块
    学习进度
    学习进度
    毕设进度
    毕设进度
  • 原文地址:https://www.cnblogs.com/zytcomeon/p/13964742.html
Copyright © 2011-2022 走看看