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 語(yǔ)句及 UNION ALL 子句來(lái)連接兩個(gè)表,如下所示:

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;
這將產(chǎn)生以下結(jié)果:

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