Академический Документы
Профессиональный Документы
Культура Документы
Sometimes, you don't know the value for a column. In a table, you can store these unknowns as
NULL. NULL means a value that is unavailable, unassigned, unknown or inapplicable. NULL is
not the same as zero or a space or any other character.
2 ways to insert NULL value in the table
1. insert into table_name values (value1, value2, null, value4);
2. insert into table_name (column1,column2,column4) values (value1, value2, value4);
Since Null does not mean 0 therefore we cannot use operators like =, >, <, etc for searching for Null
values in a column. To search for NULL values in the table we use IS NULL
example – select * from student where fees is null;
SELECT * FROM Student WHERE Name IS NULL;
Using the keyword DISTINCT, the duplicate values of the rows from a specific column can be
eliminated.
e.g.
Select Distinct Subject from teachers;OR
Select Distinct(Subject) from teachers;
The deletion will be done only in the database. This will not be displayed on the screen. To display the remaining table on
screen we use:
SELECT * FROM Student;
OUTPUT:-
DROP TABLE ;
Student tablename
After this statement Student table is fully deleted and we can no longer access it.
Q6. Display data of students in descending order of their marks but if several students have the
same value for marks, for them the display is in ascending order of names.
Ans SELECT * FROM Class ORDER BY marks desc, name;
OUTPUT:-
RollNo Name Gender Marks
3 George M 80
4 Geet F 70
1 Samidsha F 70
2 Akaash M 63