For example : SELECT Admno, Name, Place FROM Student WHERE Place IN (῾Chennai᾿, ῾Delhi᾿); 12th Computer Chapter - - Admno Name Place Ashish Chennai Adarsh Delhi Ayush Delhi Abinandh Chennai Revathi Chennai Hema Chennai The NOT IN keyword displays only those records that do not match in the list. For example: SELECT Admno, Name, Place FROM Student WHERE Place NOT IN (῾Chennai᾿, ῾Delhi᾿); will display students only from places other than “Chennai” and “Delhi”. Admno Name Place Akshith Bangalore Devika Bangalore NULL Value : The NULL value in a field can be searched in a table using the IS NULL in the WHERE clause. For example to list all the students whose Age contains no value, the command is used as: SELECT * FROM Student WHERE Age IS NULL; Non NULL values in a table can be listed using IS NOT NULL.
Note . . . ORDER BY clause The ORDER BY clause in SQL is used to sort the data in either ascending or descending based on one or more columns.
. By default ORDER BY sorts the data in ascending order. . We can use the keyword DESC to sort the data in descending order and the keyword ASC to sort in ascending order.
The ORDER BY clause is used as : SELECT <column-name>[,<column-name>,….] FROM <table-name>ORDER BY <column1>,<column2>,…ASC| DESC ; 12th Computer Chapter - - Structured Query Language For example : To display the students in alphabetical order of their names, the command is used as SELECT * FROM Student ORDER BY Name; The above student table is arranged as follows : Admno Name Gender Age Place Abinandh M Chennai Adarsh M Delhi Akshith M Bangalore Ashish M Chennai Ayush M Delhi Devika F Bangalore Hema F Chennai Revathi F Chennai The ORDER BY clause does not affect the original table. Note . . .
WHERE clause The WHERE clause is used to filter the records. It helps to extract