
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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 Articles
- A single query to get the sum of count from different tables in MySQL?
- How to get multiple rows in a single MySQL query?
- MySQL SELECT from two tables with a single query
- How can I get maximum and minimum values in a single MySQL query?
- How to count rows from two tables in a single MySQL query?
- How can I sum columns across multiple tables 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 I describe all tables in the database through a single statement in MySQL?
- Get multiple count in a single MySQL query for specific column values
- How to insert into two tables using a single MySQL query?
- How can we create a MySQL view by using data from multiple tables?
- MySQL count(*) from multiple tables?
- Multiple COUNT() for multiple conditions in a single MySQL query?
- How to obtain multiple rows in a single MySQL query?

Advertisements