
- 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
What are the several ways to add comments in MySQL query?
We can add comments in the several ways which are supported by MySQL server −
# Comment
This is a single line comment. This kind of comment starts with a # character and until the end of the line.
-– Comment
This is also a single line comment. It must be followed by space or control character.
/* Comment */
This is a multi-line comment. This syntax enables a comment to extend over multiple lines because the beginning and closing sequences need not be on the same line.
Consider the following example to demonstrate all the three types of comments −
mysql> Select NOW() #Single line comment continues to the end of line -> ; +---------------------+ | NOW() | +---------------------+ | 2017-11-07 15:04:03 | +---------------------+ 1 row in set (0.00 sec) mysql> Select NOW() -- Single line comment continues to the end of line -> ; +---------------------+ | NOW() | +---------------------+ | 2017-11-07 15:04:17 | +---------------------+ 1 row in set (0.00 sec) mysql> Select 1 /* in-line comment */ +1; +-------+ | 1 +1 | +-------+ | 2 | +-------+ 1 row in set (0.10 sec) mysql> Select 1 /* in-line comment */ +1; +-------+ | 1 +1 | +-------+ | 2 | +-------+ 1 row in set (0.00 sec) mysql> Select 1 -> /* /*> this is a Multiple-line /*> comment /*> */ -> +1; +-------+ | 1 +1 | +-------+ | 2 | +-------+ 1 row in set (0.00 sec)
- Related Articles
- How to add comments in MySQL Code?
- What are the different ways in MySQL to add ‘half year interval’ in date?
- Add results from several COUNT queries in MySQL?
- What are the comments in C#?
- What are Comments in JavaScript?
- How to add comments in the style sheet blocks
- How to add different comments in the Java code?
- What are JSP comments?
- MySQL query to replace null value with empty string in several columns while fetching data
- What are comments in Java language?
- MongoDB query to filter by several array elements?
- What are the various types of comments in JavaScript?
- What are the difference ways to replace nulls values in MySQL using SELECT statement?
- How to add a day to datetime field in MySQL query?
- MongoDB query to group several fields using aggregation framework?

Advertisements