HOME C C++ PYTHON JAVA HTML CSS JAVASCRIPT BOOTSTRAP JQUERY REACT PHP SQL AJAX JSON DATA SCIENCE AI

SQL Comments

Comments are used to explain sections of SQL statements, or to prevent execution of SQL statements.

Note: Note: Comments are not supported in Microsoft Access databases!

Single Line Comments


Single line comments start with -- .

Any text between -- and the end of the line will be ignored (will not be executed).

The following example uses a single-line comment as an explanation:

Example

--Select all:   
 SELECT  * 
 FROM  supplier  ; 
You can click on above box to edit the code and run again.
The following example uses a single-line comment to ignore the end of a line:

Example

 SELECT  * 
 FROM  supplier --WHERE City='Hydrabad' ; 
You can click on above box to edit the code and run again.

Multi-line Comments


Multi-line comments start with /* and end with /* .

Any text between /* and */ will be ignored.

The following example uses a multi-line comment as an explanation:

Example

 /*Select all the columns
of all the records
 in the employee table:*/
SELECT * FROM employee;
You can click on above box to edit the code and run again.
The following example uses a multi-line comment to ignore many statements:

Example

 /*SELECT * FROM Customers;
SELECT * FROM Products;
SELECT * FROM Categories;*/
SELECT * FROM employee;
You can click on above box to edit the code and run again.
To ignore just a part of a statement, also use the /* */ comment.

The following example uses a comment to ignore part of a line:

Example

 SELECT  Employee_name,/* City,*/ Country 
 FROM  employee; 
You can click on above box to edit the code and run again.

Output