Categories: MySQL

MySQL UNION Operator

Share

Using MySQL UNION Operator you can combine two or more result set from a multiple table into a single result set.

UNION operator eliminates duplicate rows from the result set even you forgot to use DISTINCT operator. UNION ALL allows duplicate rows remain in the result.

In the corresponding SELECT statements the number of columns appears must be equal.

Example of UNION:

SELECT userID id, userName name
FROM users
UNION
SELECT orderUser id, orderName name
FROM orders

Here we combine the data from users and orders tables into a single result set.

Recent Posts

10 Reasons Why Technology is Good for Education

Educational technology has been very helpful in the era of ever-advancing technology. It opens millions…

8 hours ago

Chat GPT Login: Step-by-Step Guide for Beginners

Have you ever thought of a world where asking the Internet for information feels like…

13 hours ago

The Sharp-Looking Guy: 5 Essential Tips for Men to Become Sharp

We've gotten so used to seeing men streetwear joggers, ripped jeans, and sleeveless shirts. Hair…

2 days ago

How to Use Your Wedding Jewellery In Unique Ways At Festivals

When it comes to festivals, the options for wedding jewellery are endless. You can go…

2 days ago

5 Tips On Window Cleaning

Whether it concerns your home or an office building, the state of a property’s windows…

2 days ago

Sustainable Business Practices: A Win-Win Strategy

You know that running an environmentally sustainable business is the right thing to do. But…

2 days ago