Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of MySQL single-line comment and multi-line comment

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains the "MySQL single-line comments and multi-line comments methods", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "MySQL single-line comments and multi-line comments method"!

In mysql, "-" is a comment character, which means a single-line comment. After the comment character, you need to add a space comment to take effect. The syntax is "--comment content"; both the comment character and the "#" comment character are used for one-line comments, except that there is no need to add spaces after the "#" comment character.

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

What does it mean in mysql?

MySQL single-line comment

1) A single-line comment can be made with a # comment character, followed by a # comment character. The format is as follows:

# comment content

An example of single-line comments using the comment character # is as follows:

# Delete duplicate lines SELECT DISTINCT product_id and purchase_price FROM Product from the result

2) single-line comments can use-- comment characters,-- you need to add a space after the comment character before the comment can take effect. The format is as follows:

-- comment content

Examples of single-line comments using comment characters-- are as follows:

-- delete duplicate lines SELECT DISTINCT product_id, purchase_price FROM Product from the result

The difference between # and-- is that the content is annotated directly after #, while the second dash of-needs to be annotated with a space character.

MySQL multiline comment

Multiline comments use the / * / comment character. / * for the beginning of the comment content and * / for the end of the comment content. The multiline comment format is as follows:

/ * comment on the first line, comment on the second line * /

Comments are written between / * and * / and can span multiple lines.

Examples of use of multiline comments are as follows

/ * this SELECT statement removes duplicate lines from the result * / SELECT DISTINCT product_id, purchase_price FROM Product

Any comment (single-line comment and multi-line comment) can be inserted in the SQL statement, and the comment can be placed anywhere in the SQL statement.

Insert a single-line comment in the SQL statement, as follows:

SELECT DISTINCT product_id, purchase_price-- removes duplicate rows from the result. FROM Product;SELECT DISTINCT product_id, purchase_price# removes duplicate rows from the result. FROM Product

Insert multiline comments in the SQL statement, as follows:

The SELECT statement SELECT DISTINCT product_id, purchase_price/*, removes duplicate rows from the result. * / FROM Product

Comments can be written in any SQL statement, and there is no limit to the number of comments in the SQL statement.

Thank you for your reading, the above is the "MySQL single-line comments and multi-line comments method" of the content, after the study of this article, I believe you on the MySQL single-line comments and multi-line comments method of this problem has a deeper understanding, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report