

- 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
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 Questions & Answers
- How to add comments in MySQL Code?
- What are the comments in C#?
- Add results from several COUNT queries in MySQL?
- What are the different ways in MySQL to add ‘half year interval’ in date?
- What are JSP comments?
- What are Comments in JavaScript?
- What are comments in Java language?
- How to add comments in the style sheet blocks
- How to add different comments in the Java code?
- What are the various types of comments in JavaScript?
- What are the ways to prevent child maltreatment?
- What are the different ways to install pandas?
- MongoDB query to filter by several array elements?
- What are the difference ways to replace nulls values in MySQL using SELECT statement?
- What are the best ways to run a meeting?
Advertisements