MySQL Comments

MySQL Comments

In MySQL, comments are used to add explanations or notes in SQL code. They are ignored by the database during execution. Comments are useful for documenting queries or temporarily disabling code.


🔹 Types of Comments in MySQL

  1. Single-Line Comment Using --



 

  • Everything after -- on the same line is ignored.

  • Must have a space after --.


  1. Single-Line Comment Using #



 

  • Everything after # on the same line is ignored.


  1. Multi-Line Comment Using /* */



 

  • Can span multiple lines.

  • Everything between /* and */ is ignored.


🔹 Examples in SQL


 

 


🔹 Key Points

  1. Comments do not affect query execution.

  2. Useful for documentation, debugging, or temporary code removal.

  3. Supports single-line (-- or #) and multi-line (/* */) comments.

CodeCapsule

Sanjit Sinha — Web Developer | PHP • Laravel • CodeIgniter • MySQL • Bootstrap Founder, CodeCapsule — Student projects & practical coding guides. Email: info@codecapsule.in • Website: CodeCapsule.in

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *