
- 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 is it possible to enter multiple MySQL statements on a single line?
As we know that a query consists of MySQL statements followed by a semicolon. We can enter multiple MySQL statements, separated by semicolons, on a single line. Consider the following example −
mysql> Select * from Student; Select * from Student ORDER BY Name; +--------+--------+--------+ | Name | RollNo | Grade | +--------+--------+--------+ | Gaurav | 100 | B.tech | | Aarav | 150 | M.SC | | Aryan | 165 | M.tech | +--------+--------+--------+ 3 rows in set (0.00 sec) +--------+--------+--------+ | Name | RollNo | Grade | +--------+--------+--------+ | Aarav | 150 | M.SC | | Aryan | 165 | M.tech | | Gaurav | 100 | B.tech | +--------+--------+--------+ 3 rows in set (0.07 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
- How is it possible for a MySQL trigger to execute multiple statements?
- How to provide multiple statements on a single line in Python?
- Is it possible to catch multiple Java exceptions in single catch block?
- A single MySQL select query on two tables is possible?
- How to get multiple rows in a single MySQL query?
- How to obtain multiple rows in a single MySQL query?
- How to make MySQL display results in a single line?
- How to alter multiple columns in a single statement in MySQL?
- How to check multiple columns for a single value in MySQL?
- How to insert multiple rows with single MySQL query?
- How can I see how long statements take to execute on the MySQL command line?
- How can we update columns values on multiple rows with a single MySQL UPDATE statement?
- Multiple COUNT() for multiple conditions in a single MySQL query?
- Is it possible to calculate a correlation in a MySQL query?
- Multiple Inserts for a single column in MySQL?

Advertisements