

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I get the output of multiple MySQL tables from a single query?
As we know that a query can have multiple MySQL statements followed by a semicolon. Suppose if we want to get the result from multiple tables then 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 example above, two statements have been entered on a single line separated by a semicolon and we got the output in sequence.
- Related Questions & Answers
- A single query to get the sum of count from different tables in MySQL?
- MySQL SELECT from two tables with a single query
- How to get multiple rows in a single MySQL query?
- How can I get maximum and minimum values in a single MySQL query?
- MySQL query to get the highest value from a single row with multiple columns
- How can I sum columns across multiple tables in MySQL?
- How to count rows from two tables in a single MySQL query?
- How can I see the description of a MySQL Temporary Tables?
- MySQL count(*) from multiple tables?
- Select the minimum value from the maximum values of two tables with a single MySQL query?
- How can I describe all tables in the database through a single statement in MySQL?
- Count NOT NULL values from separate tables in a single MySQL query
- How do I insert multiple values in a column with a single MySQL query?
- How can we get the sorted MySQL output?
- How can I get the output of a Matplotlib plot as an SVG?
Advertisements