Home > Database > Mysql Tutorial > body text

How to get the output of multiple MySQL tables from a single query?

王林
Release: 2023-09-15 18:33:03
forward
1130 people have browsed it

如何从单个查询中获取多个 MySQL 表的输出?

#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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template