Saturday , April 27 2024

PostgreSQL UNION and UNION ALL

In today’s article, we will learn how to use PostgreSQL UNION operator to combine result sets of multiple queries into a single result sets.

Things to consider when using UNION and UNION ALL:

The same number of columns must be selected in the first table and the second table; if they are different, you will receive an error.

The data types of the columns to be written in UNION and UNION ALL must be the same.

The columns and data of the Müsteriler and Personel tables are as above.

First, let’s print the recurring data for sehir once.

In the example below, we use the UNION ALL command to display all records.

Loading

About Faruk Erdem

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories