基本语法如下

sqlite> select * from tb_user;
sqlite> select userid,username from tb_user;

格式化的查询输出

sqlite> .header on
sqlite> .mode column
sqlite> select * from tb_user;

设置输出列的宽度

sqlite> .width 10, 20, 10
sqlite> select * from tb_user;

SQLite 的 ORDER BY 子句是用来基于一个或多个列按升序或降序顺序排列数据。

基本语法:SELECT column-list FROM table_name [WHERE condition] [ORDER BY column1, column2, .. columnN] [ASC | DESC];

sqlite> select * from tb_user order by name asc;        -- 结果按 name 升序排序:
sqlite> select * from tb_user order by name desc; -- 结果按 name 降序排序:
sqlite> select * from tb_user order by name,age asc; -- 结果按 name 和 age升序排序:

SQLite 的 Distinct 关键字

基本语法:SELECT DISTINCT column1, column2,.....columnN FROM table_name WHERE [condition]

sqlite> select distinct name from tb_user;
sqlite> select distinct name,age from tb_user;
sqlite> select distinct name,age from tb_user where name="liu";

  

Sqlite—查询语句(Select)的更多相关文章

  1. 如何在SQL Server查询语句(Select)中检索存储过程(Store Procedure)的结果集?

    如何在SQL Server查询语句(Select)中检索存储过程(Store Procedure)的结果集?(2006-12-14 09:25:36) 与这个问题具有相同性质的其他描述还包括:如何 ...

  2. 用mybatis将SQL查询语句”select * from user”的封装为配置文件

    用mybatis将SQL查询语句”select * from user”的封装为配置文件 定义一个xml映射文件,文件名见名知意.如user-mapper.xml,文件内容如下: <?xml v ...

  3. 阿里面试题: (a,b,c)组合索引, 查询语句select...from...where a=.. and c=..走索引吗?

    面试官:(a,b,c)组合索引,查询语句select...from...where a=.. and c=..走索引吗应聘者: 最佳左前缀法,如果索引了多列,要遵守最左前缀法则,否则索引失效 按最左前 ...

  4. MySQL查询语句(select)详解(2)

    7.子查询 当进行查询的时候,需要的条件是另外一个select语句的结果,这时候就要用到子查询 用于子查询的主要关键字有:in,not in,=,!=,exists,not exists等. 以下两张 ...

  5. NumberFormatException: Invalid int类型不匹配异常——使用SQL数据库查询语句select * from blacknumber order by _id desc limit ?,20;出现

    异常:类型不匹配 05-06 08:12:38.151: E/AndroidRuntime(14904): java.lang.NumberFormatException: Invalid int: ...

  6. SQL复杂查询语句-SELECT * FROM cs WHERE score>70 GROUP BY s_id HAVING COUNT(*)>1

    如果同时存在where,group by,的时候的执行顺序应该是这样的: 1,首先where后面添加条件把数据进行了过滤,返回一个结果集 2,然后group by将上面返回的结果集进行分组,返回一个结 ...

  7. MySQL查询语句(select)详解(1)

    1.查询记录 select*from 表名 [where 条件];eg:select*from students;//查询 students 表中所有记录,所有字段的值都显示出来select fiel ...

  8. php学习之sqlite查询语句之多条件查询

    一.PHP+Mysql多条件-多值查询示例代码: index.html代码:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitio ...

  9. SQL 简单查询语句 select

    select *from emp;//查询emp表内容

随机推荐

  1. wordpress 获取指定作者或者文章的所有评论数量

    wordpress 获取指定作者或者文章的所有评论数量 <?php $args = array( 'post_author' => '' // fill in post author ID ...

  2. centos6.7下安装glibc-2.17

    glibc  所有版本下载地址 : http://ftp.gnu.org/pub/gnu/glibc/ 安装先决条件: #yum install gcc libffi-devel python-dev ...

  3. 【Android - 控件】之MD - NavigationView的使用

    NavigationView是Android 5.0新特性——Material Design中的一个布局控件,可以结合DrawerLayout使用,让侧滑菜单变得更加美观(可以添加头部布局). Nav ...

  4. 【Android - 控件】之MD - CardView的使用

    CardView是Android 5.0新特性——Material Design中的一个布局控件,可以通过属性设置显示一个圆角的类似卡片的视图. 1.CardView的属性: app:cardCorn ...

  5. C#使用Consul集群进行服务注册与发现

    前言 我个人觉得,中间件的部署与使用是非常难记忆的:也就是说,如果两次使用中间件的时间间隔比较长,那基本上等于要重新学习使用. 所以,我觉得学习中间件的文章,越详细越好:因为,这对作者而言也是一份珍贵 ...

  6. php 设置临时内存和超时设置脚本最大执行时间

    ini_set('memory_limit','3072M'); // 临时设置最大内存占用为3G set_time_limit(0); // 设置脚本最大执行时间 为0 永不过期

  7. powerline字体安装

    安装命令 git clone https://github.com/powerline/fonts ./install.sh 了解powerline ->美化自己的命令行环境,增加漂亮的状态行, ...

  8. 八分音符(频率)卷积算子 Octave Convolution

    为什么读此系列文章? 优化数学和计算理论帮助机器学习完成问题分类: 1)按照领域划分,比如计算机视觉,自然语言处理,统计分析预测形: 2)按照算法复杂划分,比如是否是NP-Hard问题,是否需要精确解 ...

  9. Centos7使用Yum安装高版本的LNMP

    [摘要] 本文旨在介绍使用yum的方式安装一些高版本的NGINX.MySQL.PHP服务.当然如果觉得红帽给的就够用,就用红帽给的就行. 在红帽系列的Linux操作系统中,nginx/mysql/ph ...

  10. cenos基本信息和ssh

    一.查看cenos相关信息 1.查看cpu           more /proc/cpuinfo grep "model name" grep "model name ...