Select Chapter ❯
MySQL Tutorial
MySQL Union
MySQL Union is also like a Joins it combines data from two or more tables but it combines rows from two or more result sets.
Syntax
SELECT statement1 Union SELECT statement2 Union SELECT statement3....
Example of Union
SELECT student_name from student_info where student_id = '3' Union SELECT name from student_marks where sid = '3'
Code Explanation
- In this it gets all the rows where student_id and id is equal to 3 and combine the result set and display them.