EN
MySQL - Comments
0 points
In this article, we would like to show you how to use comments in MySQL.
Quick solution:
xxxxxxxxxx
1
-- Single-line comment
xxxxxxxxxx
1
/*
2
Multi-line
3
comment
4
*/
In this example, we use a single-line comment as a code fragment explanation:
xxxxxxxxxx
1
-- Select all users
2
SELECT * FROM `users`;
In this we use a single-line comment to ignore a statement at the end of the line:
xxxxxxxxxx
1
SELECT * FROM `users` -- WHERE `name`='Tom';
In this example we use a multi-line comment as a code fragment explanation:
xxxxxxxxxx
1
/* Select all
2
from the `users` table: */
3
SELECT * FROM `users`;
In this example, we use a multi-line comment to ignore many statements:
xxxxxxxxxx
1
/*SELECT * FROM `users`;
2
SELECT * FROM `products`;
3
SELECT * FROM `orders`;*/
4
SELECT * FROM `departments`;
In this example, we use a multi-line comment to ignore part of a line:
xxxxxxxxxx
1
SELECT `name`, /*`surname`*/ `country` FROM `users`;