zoukankan      html  css  js  c++  java
  • sqlite 的基本使用2

     sqlite的运算符有好几种,算术运算符,比较运算符,逻辑运算符,位运算符

    1,算术运算符

      算术运算符主要有 + - * 、 % (取余)这个很简单,举一个例子就行,要达到这样的效果需要格式化行输出 .mode line

    sqlite> select 20 % 3;
    20 % 3 = 2
    sqlite> 

    2,比较运算符

      比较运算符,只要学习过语言的基本都知道,无非就是 > ,<, ==,!=, <>(不等),>=,<=,!<(不小于),!>(不大于),这个其实也很简单,举一个例子就行

    sqlite> select * from student where id >2;
    id     name        age       
    -----  ----------  ----------
    3      cc          45        
    sqlite> 

    3,逻辑运算符

      逻辑运算符sqlite 可是有很多的

      这个就需要一一进行举例了。

    sqlite> select * from student where id == 1 and name == "aa";
    id     name        age       
    -----  ----------  ----------
    1      aa          23        
    sqlite> 
    sqlite> select * from student where id between 2 and 3;
    id     name        age       
    -----  ----------  ----------
    2      bb          12        
    3      cc          45        
    sqlite> 
    sqlite> select * from student where id in (2,3);
    id     name        age       
    -----  ----------  ----------
    2      bb          12        
    3      cc          45        
    sqlite> 
    sqlite> select * from student where id not in (2,3);
    id     name        age       
    -----  ----------  ----------
    1      aa          23        
    sqlite> 
    sqlite> select * from student where name like "b%";
    id          name        age       
    ----------  ----------  ----------
    2           bb          12        
    sqlite> 
    sqlite> select * from student where id not between 2 and 3;
    id          name        age       
    ----------  ----------  ----------
    1           aa          23        
    sqlite> 

    4,位运算符

    运算符描述实例
    & 如果同时存在于两个操作数中,二进制 AND 运算符复制一位到结果中。 (A & B) 将得到 12,即为 0000 1100
    | 如果存在于任一操作数中,二进制 OR 运算符复制一位到结果中。 (A | B) 将得到 61,即为 0011 1101
    ~ 二进制补码运算符是一元运算符,具有"翻转"位效应。 (~A ) 将得到 -61,即为 1100 0011,2 的补码形式,带符号的二进制数。
    << 二进制左移运算符。左操作数的值向左移动右操作数指定的位数。 A << 2 将得到 240,即为 1111 0000
    >> 二进制右移运算符。左操作数的值向右移动右操作数指定的位数。 A >> 2 将得到 15,即为 0000 1111

  • 相关阅读:
    window系统之mongoDB安装,启动及如何设置为windows服务(总结)
    永久激活pycharm 教程,方便,快捷,简单
    python classmethod方法 和 staticmethod
    Python 单元测试 之setUP() 和 tearDown()
    Git 自己的一些工作中的总结
    __str__ 和 __unicode__ 的区别和用法
    Bug 汇总
    如何理解API,API 是如何工作的
    AJAX
    集群配置虚拟主机及部署Hadoop集群碰到的问题
  • 原文地址:https://www.cnblogs.com/techdreaming/p/5576140.html
Copyright © 2011-2022 走看看