zoukankan      html  css  js  c++  java
  • SQLite3神奇的UNION、UNION ALL与LIMIT组合

    以此备忘:

    xxxxxx@ubuntu:~/sqlite/SQLite-036ebf72_orig_3.18.2$ ./sqlite3 t.db
    SQLite version 3.18.2 2017-06-17 09:59:36
    Enter ".help" for usage hints.
    sqlite> create table t1(id integer primary key autoincrement, data text);
    sqlite> create table t2(id integer primary key autoincrement, data text);
    sqlite> insert into t1(data) values('t1_d1');
    sqlite> insert into t1(data) values('t1_d2');
    sqlite> insert into t2(data) values('t2_d1');
    sqlite> insert into t2(data) values('t2_d2');
    sqlite> select * from t1 union select * from t2;
    1|t1_d1
    1|t2_d1
    2|t1_d2
    2|t2_d2
    sqlite> select * from(select * from(select * from t1 limit 1) union select * from(select * from t2 limit 1));
    1|t1_d1
    1|t2_d1
    sqlite> select * from(select * from(select * from t1 limit 1) union all select * from(select * from t2 limit 1));
    1|t1_d1
    sqlite>
    sqlite>
    sqlite> select * from(select * from(select * from t1 limit 2) union all select * from(select * from t2 limit 2));
    1|t1_d1
    2|t1_d2
    sqlite> select * from(select * from(select * from t1) union all select * from(select * from t2 limit 2));
    1|t1_d1
    2|t1_d2
    1|t2_d1
    2|t2_d2
    sqlite> select * from(select * from(select * from t1 limit 2) union all select * from(select * from t2));
    1|t1_d1
    2|t1_d2
    sqlite> select * from(select * from(select * from t1 limit 2) union select * from(select * from t2 limit 2));
    1|t1_d1
    1|t2_d1
    2|t1_d2
    2|t2_d2
    sqlite> select * from(select * from(select * from t1) union select * from(select * from t2 limit 2));
    1|t1_d1
    1|t2_d1
    2|t1_d2
    2|t2_d2
    sqlite> select * from(select * from(select * from t1 limit 2) union select * from(select * from t2));
    1|t1_d1
    1|t2_d1
    2|t1_d2
    2|t2_d2
    sqlite> 

    备注:aHR0cCUzQS8vd3d3LmNuYmxvZ3MuY29tL3poaGQv

  • 相关阅读:
    makefile ifeq ($(LANG),) 判断操作系统
    MIPS 指令集速查
    ps ef|grep mh* 命令
    ulimit c unlimited 命令
    kill 9 2402 命令
    chmod R 777 命令
    计算机网络总结
    source 命令
    ./ 命令
    reboot f 命令
  • 原文地址:https://www.cnblogs.com/zhhd/p/7689055.html
Copyright © 2011-2022 走看看