Page 267 - PYTHON-12
P. 267
For example, to display the name and marks of all the students who are not in the
vocational stream.
mysql> SELECT Name, Marks FROM student
WHERE NOT (Stream = ‘Vocational’);
Resultant table: student
Name Marks
Raj Kumar 93
Deep Singh 98
Ankit Sharma 76
Radhika Gupta 78
Diksha Sharma 80
Gurpreet Kaur NULL
Akshay Dureja 90
Prateek Mittal 75
8 rows in a set (0.02 sec)
12.14.3 Comments in SQL
A comment is a text which is ignored by the SQL compiler and is not executed at all. It is given for
documentation purpose only. A comment usually describes the purpose of the statement given
within an application.
SQL Comments are used to understand the functionality of the program without looking into it.
The comments give us an idea about what is written in the given SQL statement and how it works.
The comments can make an application or code easier to read as well as to maintain. A comment
can be placed between any keywords, parameters or punctuation marks in a statement. Comments
can be either single-line comments or multiple-line comments.
SQL or MySQL supports three comment styles:
F Comments beginning with – (followed by a space): The two dash lines indicate a single-
line comment in SQL statements. These single-line comments are basically used to show the
comments at the start and end of a program. A user can easily use this comment type to explain
the flow of program. This text cannot extend to a new line and ends with a line break.
F Comments beginning with #: The comments begin with ‘#’ symbol followed by the text to be
displayed for the user’s information. . This text cannot extend to a new line and ends with a line
break.
F Comments beginning with /*: Multi-line comments begin with a slash and an asterisk (/*)
followed by the text of the comment. This text can span multiple lines. The comment ends with
an asterisk and a slash (*/). The opening and terminating characters need not be separated
Relational Database and SQL
from the text by a space or a line break.
For example,
SELECT Rollno, Name, Stream
/* This statement shall display the records of all those students who are in Science stream and have
secured marks more than 75. */
FROM student # student table in use
WHERE Stream= ‘Science’ and Marks > 75; --condition for projection
12.37