![]() See the comma at the end of last_name? This means the query is expecting another column, which causes a syntax error. However, you’ll get an error, because the query is essentially doing this: SELECT If you run this query, you might think it will run and just not show the date of birth. Let’s say you have a query that has a range of columns and you want to comment one of them out. It’s in the query here, but the dashes means it is treated as a comment. When this query is run, the first_name column is not shown in the output. It’s for display purposes only.Īnother example of a comment is to exclude a column from being displayed in the SELECT clause: SELECT The two dashes at the start indicate it’s a comment. If you run this code, the line of “–Show all data” is not run. ![]() It will also show a different colour if you’re using an IDE (such as SQL Developer or SQL Server Management Studio). The code will then be “commented out” and will not be run when you run your statement. Let’s take a look at some examples of these types of comments below.Ī single-line comment is where you add two dashes “–” (or you can also use a hash “#” in MySQL) before a line of code. Let’s see what syntax can be used in each database: Database You can apply the same syntax to another line, but it just takes a bit more time.Ī multi-line comment is where multiple lines of code are commented out with the use of the symbols. There are two types of comments in SQL: single-line and multi-line (also known as a block comment).Ī single-line comment means only the one line is commented out. ![]() MySQL also allows for the hash symbol “#” to be used.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |