In This Article, You Will Know About SQL Comments.
SQL Comments – Before moving ahead, let’s know a bit about the SQL CASE Statement.
Table of Contents
SQL Comments
In SQL Comments are used to represent the statement that will not be executed. It is like an explanation statement to define why an SQL query is written.
Single-Line Comments
Single line comments start with —.
If any SQL statement starts with — sign then it will be ignored by SQL to execute.
Example: Use the single-line comment to define a SQL query.
-- Select all columns from the table Data_1
SELECT * FROM Data_1;
Example: Use the single-line comment to define a SQL query.
SELECT * FROM Data_1 -- Where Name = 'Alex';
Example: Use the single-line comment to prevent executing a SQL query.
SELECT * FROM Data_1
Where Name = 'Alex' -- Where Name = 'Rolex';
Multi-line Comments
Multi-line comments start with /* and end with */.
Any text between /* and */ will be ignored.
If any SQL statement between /* and */ sign will be ignored by SQL to execute.
Example: Use the Multi-line comment to define a SQL query.
/* Select all columns
from the table Data_1 */
SELECT * FROM Data_1;
Example: Use the Multi-line comment to define a SQL query.
/* Select columns
Name, Roll_No, and Section_ID
from the table Data_1 */
SELECT * FROM Data_1;
Example: Use the Multi-line comment to ignore statements between a SQL query.
SELECT * FROM Data_1
Where Name = 'Alex', /* Roll_No = 8 */, Section_ID = 'A';
Example: Use the Multi-line comment to ignore a part of a SQL query.
SELECT * FROM Data_1
WHERE Name LIKE 'A%'
OR Name LIKE 'R%'
/* OR Name LIKE 'S%' /*
OR Name LIKE 'K%'
ORDER BY Section_ID;
If you find anything incorrect in the above-discussed topic and have further questions, please comment below.
Get Started: SQL Comments
In This Article, You Will Know About SQL Comments.
SQL Comments – Before moving ahead, let’s know a bit about the SQL CASE Statement.
Table of Contents
SQL Comments
In SQL Comments are used to represent the statement that will not be executed. It is like an explanation statement to define why an SQL query is written.
Single-Line Comments
Single line comments start with —.
If any SQL statement starts with — sign then it will be ignored by SQL to execute.
Example: Use the single-line comment to define a SQL query.
Example: Use the single-line comment to define a SQL query.
Example: Use the single-line comment to prevent executing a SQL query.
Multi-line Comments
Multi-line comments start with /* and end with */.
Any text between /* and */ will be ignored.
If any SQL statement between /* and */ sign will be ignored by SQL to execute.
Example: Use the Multi-line comment to define a SQL query.
Example: Use the Multi-line comment to define a SQL query.
Example: Use the Multi-line comment to ignore statements between a SQL query.
Example: Use the Multi-line comment to ignore a part of a SQL query.
If you find anything incorrect in the above-discussed topic and have further questions, please comment below.
Connect on:
Recent Post
Python Dictionary Beginner Project: Python Dictionary Projects to Enhance Your Coding Skills
Python Set Beginner Project: union(), intersection(), difference(), symmetric_difference()
Python Set Methods 101: A Beginner Guide to Python Set
Python Set Project: A Practical Set Project for Beginners
Python List Data Type Project for Beginners: Unlocking Python Lists
Popular Post
Introduction to Python SciPy Statistical Significance Tests
DSA: Algorithm Definition and its Characteristics
Introduction to Python NumPy Differences
Why is Python not a good choice for a project?
Top 10 Python Projects Programmers Should Try
Top Articles
Escape Sequence Character in Python
Get Started: Python MySQL Update Table
Python Packages: Top 10 Python Packages in 2022
Ten Ethical Hacking Programming Languages For Using In 2022
7 Programming Languages to Get You a High Job in MNCs
Archives
Categories
Tags
Share on