0% found this document useful (0 votes)
2 views

SQL Comments

Uploaded by

Anum Masood
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

SQL Comments

Uploaded by

Anum Masood
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

SQL
1. SQL COMMANDS
COMMANDS FOR
FOR BEGINNERS
BEGINNERS

2. CREATE
2. CREATE AA WEB
WEB PAGE
PAGE

SQL Comments
‹ Previous Next ›

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

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 Get your own SQL Server

-- Select all:
SELECT * FROM Customers;
 Tutorials  Exercises  Certificates  Services  Search...

HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS

SQL Tutorial Try it Yourself »

SQL HOME
SQL Intro
The following example uses a single-line comment
SQL Syntax
to ignore the end of a line:
SQL Select
SQL Select Distinct
SQL Where
Example
SQL Order By
SQL And
SELECT * FROM Customers -- WHERE
SQL Or City='Berlin';
SQL Not
SQL Insert Into
Try it Yourself »
SQL Null Values
SQL Update
SQL Delete
The following example uses a single-line comment
SQL Select Top
to ignore a statement:
SQL Aggregate Functions
SQL Min and Max
SQL Count
Example
SQL Sum
SQL Avg
-- SELECT * FROM Customers;
SQL Like SELECT * FROM Products;
SQL Wildcards
SQL In
Try it Yourself »
SQL Between
SQL Aliases
SQL Joins
SQL Inner Join
SQL Left Join Search for
SQL Right Join
SQL Full Join 1. SQL Database Commands ›
SQL Self Join
SQL Union
2. SQL for Beginners ›
SQL Group By
SQL Having
SQL Exists
3. SQL Select Statement ›
SQL Any, All
SQL Select Into
SQL Insert Into Select
SQL Case
SQL Null Functions
SQL Stored Procedures Multi-line Comments
SQL Comments
Multi-line comments start with /* and end with
SQL Operators */ .

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


SQL Database
SQL Create DB The following example uses a multi-line comment
SQL Drop DB as an explanation:
SQL Backup DB
SQL Create Table
SQL Drop Table Example
SQL Alter Table
SQL Constraints /*Select all the columns
SQL Not Null of all the records
in the Customers table:*/
SQL Unique
SELECT * FROM Customers;
SQL Primary Key
SQL Foreign Key
SQL Check
Try it Yourself »
SQL Default
SQL Index
SQL Auto Increment The following example uses a multi-line comment
to ignore many statements:
SQL Dates
SQL Views
SQL Injection
SQL Hosting
Example
SQL Data Types
/*SELECT * FROM Customers;
SELECT * FROM Products;
SQL References
SELECT * FROM Orders;
SQL Keywords  SELECT * FROM Categories;*/
MySQL Functions  SELECT * FROM Suppliers;
SQL Server Functions 
MS Access Functions  Try it Yourself »
SQL Quick Ref

SQL Examples To ignore just a part of a statement, also use the


SQL Examples /* */ comment.
SQL Editor
The following example uses a comment to ignore
SQL Quiz
part of a line:
SQL Exercises
SQL Server
SQL Bootcamp
Example
SQL Certificate

SELECT CustomerName, /*City,*/ Country


FROM Customers;

Try it Yourself »

The following example uses a comment to ignore


part of a statement:

Example

SELECT * FROM Customers WHERE


(CustomerName LIKE 'L%'
OR CustomerName LIKE 'R%' /*OR
CustomerName LIKE 'S%'
OR CustomerName LIKE 'T%'*/ OR
CustomerName LIKE 'W%')
AND Country='USA'

You might also like