{"id":287,"date":"2018-12-13T08:05:30","date_gmt":"2018-12-13T08:05:30","guid":{"rendered":"https:\/\/barkhane.com\/sql\/2018\/12\/13\/sql-comments\/"},"modified":"2024-03-03T17:54:07","modified_gmt":"2024-03-03T17:54:07","slug":"sql-comments","status":"publish","type":"post","link":"https:\/\/barkhane.com\/sql\/sql-comments\/","title":{"rendered":"SQL Comments"},"content":{"rendered":"<p>In SQL Comments, you can comment your code just like any other language. Comments can appear on a single line or span across multiple lines. Let\\&#8217;s explore how to comment your SQL statements.<\/p>\n<p>Syntax<br \/>\nThere are two syntaxes that you can use to create a comment in SQL.<\/p>\n<p>Syntax Using &#8212; symbol<br \/>\nThe syntax for creating a comment in SQL using &#8212; symbol is:<\/p>\n<p>&#8212; comment goes here<br \/>\nA comment started with &#8212; symbol must be at the end of a line in your SQL statement with a line break after it. This method of commenting can only span a single line within your SQL and must be at the end of the line.<\/p>\n<p>Syntax Using \/* and *\/ symbols<br \/>\nThe syntax for creating a comment in SQL using \/* and *\/ symbols is:<\/p>\n<p>\/* comment goes here *\/<br \/>\nA comment that starts with \/* symbol and ends with *\/ and can be anywhere in your SQL statement. This method of commenting can span several lines within your SQL.<\/p>\n<p>Example &#8211; Comment on a Single Line<br \/>\nLet\\&#8217;s look at an example that shows how to create a comment in SQL that is on a single line.<\/p>\n<p>For example:<\/p>\n<p>Here is a comment that appears on its own line in SQL:<\/p>\n<p>SELECT websites.site_name<br \/>\n\/* comments *\/<br \/>\nFROM websites;<br \/>\nHere is a comment that appears in the middle of the line in SQL:<\/p>\n<p>SELECT \/* comments *\/ websites.site_name<br \/>\nFROM websites;<br \/>\nHere is a comment that appears at the end of the line in SQL:<\/p>\n<p>SELECT websites.site_name \/* comments *\/<br \/>\nFROM websites;<br \/>\nor<\/p>\n<p>SELECT websites.site_name &#8212; comments<br \/>\nFROM websites;<br \/>\nExample &#8211; Comment on Multiple Lines<br \/>\nYou can also create a comment that spans multiple lines in your SQL statement.<\/p>\n<p>For example:<\/p>\n<p>SELECT websites.site_name<br \/>\n\/*<br \/>\n* comments<br \/>\n* Purpose: To show a comment that spans multiple lines in your SQL statement.<br \/>\n*\/<br \/>\nFROM websites;<br \/>\nThis comment spans across multiple lines in SQL and in this example, it spans across 4 lines.<\/p>\n<p>You can also create a comment that spans multiple lines using this syntax:<\/p>\n<p>SELECT websites.site_name \/* comments<br \/>\nPurpose: To show a comment that spans multiple lines in your SQL statement. *\/<br \/>\nFROM websites;<br \/>\nSQL will assume that everything after the \/* symbol is a comment until it reaches the *\/ symbol, even if it spans multiple lines within the SQL statement. So in this example, the comment will span across 2 lines.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In SQL Comments, you can comment your code just like any other language. Comments can appear on a single line [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[2],"tags":[],"class_list":["post-287","post","type-post","status-publish","format-standard","hentry","category-sql"],"_links":{"self":[{"href":"https:\/\/barkhane.com\/sql\/wp-json\/wp\/v2\/posts\/287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/barkhane.com\/sql\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/barkhane.com\/sql\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/barkhane.com\/sql\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/barkhane.com\/sql\/wp-json\/wp\/v2\/comments?post=287"}],"version-history":[{"count":0,"href":"https:\/\/barkhane.com\/sql\/wp-json\/wp\/v2\/posts\/287\/revisions"}],"wp:attachment":[{"href":"https:\/\/barkhane.com\/sql\/wp-json\/wp\/v2\/media?parent=287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/barkhane.com\/sql\/wp-json\/wp\/v2\/categories?post=287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/barkhane.com\/sql\/wp-json\/wp\/v2\/tags?post=287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}