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