:: DEVELOPER ZONE
The MySQL server supports three comment styles:
From a '#' character to the end of the line.
From a '-- ' sequence to the end of the line.
This style is supported as of MySQL 3.23.3. Note that the
'-- ' (double-dash) comment style requires the
second dash to be followed by at least one space (or by a control
character such as a newline). This syntax differs slightly from
standard SQL comment syntax, as discussed in
Section 1.7.5.7, “'--' as the Start of a Comment”.
From a '/*' sequence to the following
'*/' sequence. The closing sequence need not be
on the same line, so this syntax allows a comment to extend over
multiple lines.
The following example demonstrates all three comment styles:
mysql> SELECT 1+1; # This comment continues to the end of line mysql> SELECT 1+1; -- This comment continues to the end of line mysql> SELECT 1 /* this is an in-line comment */ + 1; mysql> SELECT 1+ /* this is a multiple-line comment */ 1;
The comment syntax just described applies to how the
mysqld server parses SQL statements. The
mysql client program also performs some parsing of
statements before sending them to the server. (For example, it does
this to determine statement boundaries within a multiple-statement
input line.) However, there are some limitations on the way that
mysql parses /* ... */
comments:
A semicolon within the comment is taken to indicate the end of the current SQL statement and anything following it to indicate the beginning of the next statement. This problem was fixed in MySQL 4.0.13.
A single quote, double quote, or backtick character is taken to
indicate the beginning of a quoted string or identifier, even within
a comment. If the quote is not matched by a second quote within the
comment, the parser doesn't realize the comment has ended. If you
are running mysql interactively, you can tell
that it has gotten confused like this because the prompt changes
from mysql> to '>,
">, or `>. This problem
was fixed in MySQL 4.1.1.
An exclamation point used with this style of comment delimiter (such
as /*! ... */) marks portions of SQL statements
for conditional execution. For more information and examples, see
Section 1.7.4, “MySQL Extensions to Standard SQL”.
For affected versions of MySQL, these limitations apply both when you
run mysql interactively and when you put commands
in a file and use mysql in batch mode to process
the file with mysql <
file_name.
© 1995-2005 MySQL AB. All rights reserved.

User Comments
Warning: query failed: Unknown column 'user.firstname' in 'field list' in /data0/sites/live/web-main/lib/mysql-cxn.php on line 69
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /data0/sites/live/web-main/lib/docbook.php on line 245
Add your own comment.