unions

n. Union; union (plural noun of union); harmony; marriage

all

British [ɔ:l] American [ɔl]

adj. all; everything; all kinds; extreme, as much as possible

pron. all; everything; everyone, everything thing; all situations

adv.entirely; completely; each; extremely etc.] (someone) everything

SQLite UNION ALL function syntax

Function:The UNION ALL operator is used to combine the results of two SELECT statements, including duplicate rows.

The rules that apply to UNION also apply to the UNION ALL operator.

Grammar: The basic syntax of UNION ALL is as follows:

SELECT column1 [, column2 ]
FROM table1 [, table2 ]
[WHERE condition]

UNION ALL

SELECT column1 [, column2 ]
FROM table1 [, table2 ]
[WHERE condition]

The conditions given here can be as needed any expression.

SQLite UNION ALL function example

让我们使用 SELECT 语句及 UNION ALL 子句来连接两个表,如下所示:

sqlite> SELECT EMP_ID, NAME, DEPT FROM COMPANY INNER JOIN DEPARTMENT
        ON COMPANY.ID = DEPARTMENT.EMP_ID
   UNION ALL
     SELECT EMP_ID, NAME, DEPT FROM COMPANY LEFT OUTER JOIN DEPARTMENT
        ON COMPANY.ID = DEPARTMENT.EMP_ID;
这将产生以下结果:

EMP_ID      NAME                  DEPT
----------  --------------------  ----------
1           Paul                  IT Billing
2           Allen                 Engineerin
3           Teddy                 Engineerin
4           Mark                  Finance
5           David                 Engineerin
6           Kim                   Finance
7           James                 Finance
1           Paul                  IT Billing
2           Allen                 Engineerin
3           Teddy                 Engineerin
4           Mark                  Finance
5           David                 Engineerin
6           Kim                   Finance
7           James                 Finance