• 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

  • 相关阅读:
    JavaWeb网站技术架构
    fullcalendar插件日程管理
    PuTTY/终端使用复制、粘贴
    JAVA PERSISTENCE API (JPA)
    mysql查询当天所有数据sql语句
    Sign http
    js在新页面中返回到上一页浏览的历史位置
    Android使用Activity用作弹出式对话框
    android listview局部刷新和模拟应用下载
    如何获取drawable目录下的图片绝对路径
  • 原文地址:https://www.cnblogs.com/techdreaming/p/5576140.html
Copyright © 2020-2023  润新知