June 12, 2019
There are two ways to add a comment to a SQL query - using
/* */ and
--. The differences are as follows:
With a comment surrounded by
*/, the comment can span multiple lines. That is not the case for the two-hyphen approach where each new line would require a repeat of the hyphens.
In both cases, however, there is no need for a space between the asterisk and the first/last character.
select * from my_table /*Select every field from my_table*/ where last_name = 'jones' /* for people with the last name jones */ and age > 30 -- where they are greater than 30 years of age --but not 30 years
Thanks for reading! My name's Stephen Weiss. I live in Chicago with my wife, Kate, and dog, Finn.
Click here to see the archives of my weeks in review and sign up yourself!