zoukankan      html  css  js  c++  java
  • UNION UNION-ALL

    The UNION ALL operator may be what you are looking for.

    With this operator, you can concatenate the resultsets from multiple queries together, preserving all of the rows from each. Note that a UNION operator (without the ALL keyword) will eliminate any "duplicate" rows which exist in the resultset. The UNION ALL operator preserves all of the rows from each query (and will likely perform better since it doesn't have the overhead of performing the duplicate check and removal operation).

    The number of columns and data type of each column must match in each of the queries. If one of the queries has more columns than the other, we sometimes include dummy expressions in the other query to make the columns and datatypes "match". Often, it's helpful to include an expression (an extra column) in the SELECT list of each query that returns a literal, to reveal which of the queries was the "source" of the row.

    SELECT 'q1' AS source, a, b, c, d FROM t1 WHERE ...
    UNION ALL
    SELECT 'q2', t2.fee, t2.fi, t2.fo, 'fum' FROM t2 JOIN t3 ON ...
    UNION ALL
    SELECT 'q3', '1', '2', buckle, my_shoe FROM t4
  • 相关阅读:
    async中series的实现 javascript构件
    6.算法-计数排序
    5.算法-快速排序
    4.堆排序
    3.分治法研究-搜索数组中的最长连续递增子集
    字典树(Trie)学习笔记
    并查集笔记
    求树的遍历
    P1087 FBI树
    P5017 摆渡车
  • 原文地址:https://www.cnblogs.com/kakaisgood/p/9341886.html
Copyright © 2011-2022 走看看