#We know that a query can have multiple MySQL statements, followed by a semicolon. Suppose if we want to get results from multiple tables, consider the following example to get the result set from "Student_info" and "Student_detail" by writing a single query -
mysql> Select Name, Address from Student_info; Select Studentid, Address from Student_detail; +---------+------------+ | Name | Address | +---------+------------+ | YashPal | Amritsar | | Gaurav | Chandigarh | | Raman | Shimla | | Ram | Jhansi | | Shyam | Chandigarh | | Mohan | Delhi | | Saurabh | NULL | +---------+------------+ 7 rows in set (0.00 sec) +-----------+------------+ | Studentid | Address | +-----------+------------+ | 100 | Delhi | | 101 | Shimla | | 103 | Jaipur | | 104 | Chandigarh | | 105 | Chandigarh | +-----------+------------+ 5 rows in set (0.00 sec)
In the above example, enter in one line With two statements separated by semicolons, we get the output in order.
The above is the detailed content of How to get the output of multiple MySQL tables from a single query?. For more information, please follow other related articles on the PHP Chinese website!