Do you want to be a good Web Developer?

Enter Your Email To Get Our Exclusive Tutorials
And Offer Right In Your Email

MySQL Union

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

Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email