我们知道一个查询可以有多个 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 表的输出?的详细内容。更多信息请关注PHP中文网其他相关文章!