Home > Database > SQL > body text

What are the keywords that represent union in sql

下次还敢
Release: 2024-05-01 23:42:30
Original
922 people have browsed it

In SQL, the keyword for union is UNION, which is used to combine the results of multiple SELECT statements into a single result set that contains all unique rows.

What are the keywords that represent union in sql

Keywords representing union in SQL

In SQL, the keywords representing union are:

  • UNION

Using UNION

UNION keyword is used for Combines the results of two or more SELECT statements into a single result set. The result set contains all unique rows from both input tables.

Syntax:

<code class="sql">SELECT 列名1, 列名2, ...
FROM 表名1
UNION
SELECT 列名1, 列名2, ...
FROM 表名2;</code>
Copy after login

For example:

<code class="sql">SELECT name, city
FROM table1
UNION
SELECT name, city
FROM table2;</code>
Copy after login

The above query will return table1 and table2 The name and city columns for all unique rows in the table.

The above is the detailed content of What are the keywords that represent union in sql. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!