In MySQL, comments can be added to SQL queries to improve readability and understanding of the code. There are two types of comments in MySQL:
1. Single-line comments: These comments start with -- and continue to the end of the line.
SELECT * FROM table_name; -- This is a single-line comment
2. Multi-line comments: These comments start with /* and end with */. They can span multiple lines.
/*
This is a multi-line comment
It can span multiple lines
*/
SELECT * FROM table_name;
Comments are ignored by the MySQL parser and have no effect on query execution. They are purely for human readability and can be used to document SQL code, explain complex queries, or temporarily disable parts of a query for testing purposes.