All TalkersCode Topics

Follow TalkersCode On Social Media

devloprr.com - A Social Media Network for developers Join Now ➔

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.

❮ PrevNext ❯