The keyword representing union in SQL is UNION. The UNION operator combines rows from two or more tables into a single result set, retaining only unique rows. The syntax is: SELECT column1, column2, ... FROM table1 UNION SELECT column1, column2, ... FROM table2;. For example, to find all the names of students and teachers, we can use the following query: SELECT name FROM students UNION SELECT name FROM teachers;.
The keyword representing union in SQL: UNION
Union is an operator in SQL. Used to merge rows from two or more tables into a single result set, retaining only unique rows. The UNION keyword is used to perform this operation.
Syntax:
<code class="sql">SELECT column1, column2, ... FROM table1 UNION SELECT column1, column2, ... FROM table2;</code>
Example:
Suppose there are two tables, students
and teachers
. We want to find the names of all students and teachers:
<code class="sql">SELECT name FROM students UNION SELECT name FROM teachers;</code>
The result will contain the names of students and teachers without duplicates.
The above is the detailed content of The keyword representing union in sql is. For more information, please follow other related articles on the PHP Chinese website!