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)