Home > Database > Mysql Tutorial > What is the syntax of UNION operator in mysql

What is the syntax of UNION operator in mysql

WBOY
Release: 2023-05-28 13:46:12
forward
1311 people have browsed it

What is the UNION operator in mysql?

The MySQL UNION operator is used to combine the results of two or more SELECT statements into a result set.

Multiple SELECT statements will delete duplicate data.

UNION operator syntax:

SELECT column_name(s) FROM table1
UNION
SELECT column_name(s) FROM table2;
Copy after login

Note: The column name in the UNION result set is always equal to the first SELECT in UNION Column names in statements.

Usage example: Select all different countries (only different values) from the "Websites" and "app" tables

SELECT country FROM Websites
UNION
SELECT country FROM app
ORDER BY country;
Copy after login

The above is the detailed content of What is the syntax of UNION operator in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
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