We can add comments through several methods supported by MySQL server -
This is a single-line comment. Such comments start with the # character and continue until the end of the line.
This is also a single-line comment. Must be followed by a space or control character.
This is a multi-line comment. This syntax allows comments to be extended to multiple lines because the start and end sequences do not have to be on the same line.
Consider the following example to demonstrate all three types of comments - p>
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)
The above is the detailed content of What are the ways to add comments in MySQL queries?. For more information, please follow other related articles on the PHP Chinese website!