Home > Database > Mysql Tutorial > What are the ways to add comments in MySQL queries?

What are the ways to add comments in MySQL queries?

WBOY
Release: 2023-08-28 11:33:02
forward
851 people have browsed it

What are the ways to add comments in MySQL queries?

We can add comments through several methods supported by MySQL server -

# Comment

This is a single-line comment. Such comments start with the # character and continue until the end of the line.

-– Comment

This is also a single-line comment. Must be followed by a space or control character.

/* Comment */

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template