Mysql UNION Query

The UNION query is used to combine the result-set of two or more SELECT statements.

Unions combine the results from multiple SELECT queries into a consolidated result set.

First you can need database connection in php

Code

$sql = "SELECT * FROM product UNION SELECT * FROM users"; 
$result = mysqli_query($con,$sql);
while($row = mysqli_fetch_assoc($result))
{

}

Leave a Reply

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