Docsity

Database Management System: SQL Query Basics, Slides of Introduction to Database Management Systems

Partial preview of the text

Download Database Management System: SQL Query Basics and more Slides Introduction to Database Management Systems in PDF only on Docsity!

Database

Management

System

Lecture - 29

Where: Format

SELECT [ALL|DISTINCT]

{*|culumn_list [alias][,…..n]}

FROM table_name

[WHERE <search_condition>]

Where Example

Q: Display all courses of the MCS

program

Select crCode, crName, prName

from course

where prName = ‘MCS’

Not Operator

Inverses the predicate’s value

Q: List the course names offered to

programs other than MCS

SELECT crCode, crName, prName

FROM course

WHERE not (prName = ‘MCS’)

The BETWEEN Operator

Checks the value in a range
Q: List the IDs of the students with course
codes having marks between 70 and 80
SELECT stId, crCode, totMrks
From ENROLL
WHERE totMrks between 70 and 80

SELECT crName, prName

From course

Where (prName = ‘MCS’) OR

(prName = ‘BCS’)

“Order By” Clause

Sorts the rows in a particular order

SELECT select_list
FROM table_source
[ WHERE search_condition ]
[ ORDER BY order_expression [ ASC | DESC ]
[,……n]
]