Tuesday 13 November 2018

How can I add comments in MySQL?

I want to add comment in SQL code. How can I do this? I'm using MySQL.

 Answers


Several ways:
# Comment
-- Comment
/* Comment */
See the docs.



You can use single line comments:
-- this is a comment
# this is also a comment
Or a multiline comment:
/*
   multiline
   comment
*/



Three types of commenting are supported
  1. Hash base single line commenting using #
    Select * from users ; # this will list users
    
    1. Double Dash commenting using --
    Select * from users ; -- this will list users
Note : Its important to have single white space just after --
3) Multi line commenting using /* */
Select * from users ; /* this will list users */

0 comments:

Post a Comment