如何从单个查询获取多个MySQL表的输出?
我们知道一个查询可以有多个MySQL语句,后跟一个分号。假设如果我们要从多个表中获取结果,则请看以下示例,通过编写单个查询从“ Student_info”和“ Student_detail”中获取结果集-
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)
在上面的示例中,在由分号分隔的一行上输入了两个语句,并且按顺序获得了输出。
以上是 如何从单个查询获取多个MySQL表的输出? 的全部内容, 来源链接: utcz.com/z/349022.html