Docsity

Database Management System Lecture 28: Select Statement and Expression, Slides of Introduction to Database Management Systems

Partial preview of the text

Download Database Management System Lecture 28: Select Statement and Expression and more Slides Introduction to Database Management Systems in PDF only on Docsity!

Database

Management

System

Lecture - 28

Insert

COURSE (crCode, crName, crCredits, prName)

INSERT INTO course VALUES (‘CS-211', ‘Operating Systems’, 4, ‘MCS’) INSERT INTO course (crCode, crName) VALUES (‘CS-316’, Database Systems’) INSERT INTO course (‘MG-103’, ‘Intro to Management’, NULL, NULL)

Select Statement Maximum used command in DML Used not only to select certain rows but also the columns Also used for different forms of product, that is, different joins

Select Selecting rows from one or more tables SELECT {*|col_name[,….n]} FROM table_name

Select Q: Give the names of the students with the program name SELECT stName, prName FROM student

Attribute Alias

Another Name “Urf” for an attribute SELECT {*|col_name [[AS] alias] [, …n]} FROM tab_name SELECT stName as ‘Student Name’ , prName ‘Program’ FROM Student

Expression Example Q: Display the total sessional marks of each student obtained in each subject Select stId, crCode, mTerm + sMrks ‘Total out of 50’ from enroll

Select Distinct The DISTINCT keyword is used to return only distinct (different) values

Q: Get the program names in which students are enrolled SELECT prName FROM Student Select Distinct