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

  • 相关阅读:
    android selector失效的原因
    Android TabActivity使用方法
    Android Build.VERSION.SDK_INT兼容介绍
    数组与指针
    字符串与字符串函数
    C控制语句:分支和跳转
    C控制语句:循环
    运算符、表达式、语句
    select
    正则验证数字
  • 原文地址:https://www.cnblogs.com/techdreaming/p/5576140.html
Copyright © 2011-2022 走看看