Code Commenting

Comments are used to explain sections of the code within the query. A single-line comment is created by inserting ‘–‘ at the beginning of the line. Comments also allow us to ignore code sections, which is useful when testing queries.


SELECT column1
-- , column2
, column3
FROM Table1
WHERE condition1

The above query will only return columns 1 and 3 because column 2 has been commented out of the query.

There are also multi-line comments, which we open with ‘/‘ and close with ‘/’.


/* Select all
employees from Warsaw
in the Employees table */
FROM Employees
WHERE City ='Warsaw';

Important! Comments are an essential part of the code, and it is good practice to use them. This allows other users to understand the code more easily, and when used correctly, it improves code readability.

Interesting article? Share further!

Leave A Comment