Hacking with PHP has been updated for PHP 7 - click here! >>

SQL comments

Before you start diving into the world of SQL, just a short note about commenting your SQL code. In SQL, there are a number of ways to comment your code, of which the most popular are /* */ and #, both of which are seen in PHP. Of the two, # is more popular - like PHP, it comments to the end of the line.

Author's Note: I personally find # good for SQL because I never use it in PHP scripts - it makes the distinct between complex SQL queries and PHP code that little bit more obvious. Choose what fits you best.


If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: Interacting with MySQL >>

Previous chapter: SQL

Jump to:


Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.