MySQL
- Introduction To MySQL
- MySQL RDBMS
- MySQL SQL
- MySQL SELECT Statement
- MySQL WHERE Clause
- MySQL AND, OR And NOT Operators
- MySQL ORDER BY Keyword
- MySQL INSERT INTO Statement
- MySQL NULL Values
- MySQL UPDATE Statement
- MySQL DELETE Statement
- MySQL LIMIT Clause
- MySQL MIN() And MAX() Functions
- MySQL COUNT(), AVG() And SUM() Functions
- MySQL LIKE Operator
- MySQL Wildcards
- MySQL IN Operator
- MySQL BETWEEN
- MySQL Aliases
- MySQL Joins
- MySQL INNER JOIN Keyword
- MySQL LEFT JOIN Keyword
- MySQL RIGHT JOIN Keyword
- MySQL CROSS JOIN Keyword
- MySQL Self Join
- MySQL UNION Operator
- MySQL GROUP BY Statement
- MySQL HAVING Clause
- MySQL EXISTS Operator
- MySQL ANY And ALL Operators
- MySQL INSERT INTO SELECT Statement
- MySQL CASE Statement
- MySQL NULL Functions
- MySQL Comments
- MySQL Operators
- MySQL CREATE DATABASE Statement
- MySQL DROP DATABASE Statement
- MySQL CREATE TABLE Statement
- MySQL DROP TABLE Statement
- MySQL ALTER TABLE Statement
- MySQL Constraints
- MySQL NOT NULL Constraint
- MySQL UNIQUE Constraint
- MySQL PRIMARY KEY Constraint
- MySQL FOREIGN KEY Constraint
- MySQL CHECK Constraint
- MySQL DEFAULT Constraint
- MySQL CREATE INDEX Statement
- MySQL AUTO INCREMENT Field
- MySQL Working With Dates
- MySQL Views
- MySQL Data Types
- MySQL Functions
MySQL Comments
MySQL Comments
Comments are used to explain sections of SQL statements, or to prevent execution of SQL statements.
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:
-- Select all:
SELECT * FROM Customers;
SELECT * FROM Customers;
The following example uses a single-line comment to ignore the end of a line:
SELECT * FROM Customers -- WHERE City='Berlin';
The following example uses a single-line comment to ignore a statement:
-- SELECT * FROM Customers;
SELECT * FROM Products;
SELECT * FROM Products;
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:
/*Select all the columns
of all the records
in the Customers table:*/
SELECT * FROM Customers;
of all the records
in the Customers table:*/
SELECT * FROM Customers;
The following example uses a multi-line comment to ignore many statements:
/*SELECT * FROM Customers;
SELECT * FROM Products;
SELECT * FROM Orders;
SELECT * FROM Categories;*/
SELECT * FROM Suppliers;
SELECT * FROM Products;
SELECT * FROM Orders;
SELECT * FROM Categories;*/
SELECT * FROM Suppliers;
To ignore just a part of a statement, also use the /* */ comment.
The following example uses a comment to ignore part of a line:
SELECT CustomerName, /*City,*/ Country FROM Customers;
The following example uses a comment to ignore part of a statement:
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'
ORDER BY CustomerName;
OR CustomerName LIKE 'R%' /*OR CustomerName LIKE 'S%'
OR CustomerName LIKE 'T%'*/ OR CustomerName LIKE 'W%')
AND Country='USA'
ORDER BY CustomerName;
MySQL Comparison Operators
Operator | Description | Example |
---|---|---|
= | Equal to | Try it |
> | Greater than | Try it |
< | Less than | Try it |
>= | Greater than or equal to | Try it |
<= | Less than or equal to | Try it |
<> | Not equal to | Try it |