

MySQL looks inside this special type ofcomment and uses the keywords, but other database servers will ignore them aspart of the comment.
#Mysql comment single line code#
Still, it is only a heuristic, and it's probably better to usethe ' #' or ' /*.*/' comment styles andresort to double dashes only when writing code that you may port to otherdatabases that don't understand the other comment styles.Īs of MySQL 3.22.7, you can "hide" MySQL-specific keywords inC-style comments by beginning the comment with ' /*!' ratherthan with ' /*'. It's not likelyyou'd write such an expression as 5- 7, so this is a usefulheuristic. Statements with expressions like 5-7 might be taken ascontaining a comment starting sequence otherwise. MySQL allows this but requires the space as an aid fordisambiguation. Some other databases use the doubledash to begin a comment. That is, anything between the ' /*' and' */' beginning and ending markers is considered a comment.C-style comments can span multiple lines: # this is a single line comment/* this is also a single line comment *//* this, however, is a multiple line comment*/Ī third comment style is available as of MySQL 3.23.3: Begin the comment withtwo dashes and a space (' - ') everything from the dashes tothe end of the line is treated as a comment. Second, C-style commentsare allowed as well. First, anything from a ' #'character to the end of a line is considered a comment. This can beuseful for documenting queries that you store in files. MySQL allows you to intersperse comments with your SQL code. SQL in 24 Hours, Sams Teach Yourself, 7th Edition
