zoukankan      html  css  js  c++  java
  • sqlite查询语句

    搜索距现在六个月前的月份第一天日期:

    SELECT date('now','start of month','-6 month','0 day');

    搜索距现在六个月前的日期:

    SELECT date('now','-6 month','0 day');

    case when 用法:

    栗子:

    select case when a = "1" then "v" end from table;

    or

    select case a when "1" then "v" end from table;

    记住一定要用end包住条件,对一个字段套多个case when语句只能执行一次,比如这样:

    select case when name like "%a%" then replace(name,'a','A')
                when name like "%b%" then replace(name,'b','B')
                when name like "%c%" then replace(name,'c','C') 
           else name end as SB ,*
    from table;

    这个语句的目的是对name字段进行部分替换,他只能替换a,b,c中的一个

    如果如要全部替换需要套很多个replace()

    select replace(replace(replace(name,"a",A),"b","B"),"c","C") from table;

    很麻烦,而且数据量大的情况下执行效率很低

    日期加减用julianday():

    select julianday('now') - julianday('1776-07-04');

  • 相关阅读:
    牌库读取的修复
    法术迸发(Spellburst)
    传染孢子的探索
    降低电脑功耗——降低笔记本风扇噪音
    Playfield 类方法的注释
    大陆争霸( 最短路变形)
    POJ 2406 Power String
    括号匹配
    HDU 1003 最大子段和
    6.19noip模拟赛总结
  • 原文地址:https://www.cnblogs.com/guojia314/p/11237799.html
Copyright © 2011-2022 走看看