SQL (Structured Query Langauge)
SQL (Structured Query Langauge)
Where city <> “Delhi” and marks>96; Rollno Name Marks City
8 Riya 97 Mumbai
Rollno Name Marks City 20 Deepak 98 Mumbai
8 Riya 97 Mumbai
20 Deepak 98 Mumbai
Selecting data between a
Selecting based on a list Range
of data Between value and value
Aggregate functions
Example
Count(), max(), min(), sum(), avg()
Select data of students whose name are
starting from “R” Select count(*) as Total from student;
From student;
Displaying data in Specific Count( Max( Min(m Sum( Avg(m
marks) marks) arks) marks) arks)
order (Ascending or 5 98 96 487 97.40
Descending) 00
From student
Select * from student
Group by city;
Order by name desc;
City Total
Rollno Name Marks City Agra 1
Delhi 2 103 Data Structure
Mumbai 2 105 Computer Networks
102 SQL
Library
Id Book
Equi- Join
Select * from student, library
Where student.id=library.id;
Using alias
Where s.id=l.id;
Result Table
Student
Id Name Marks Id Book
102 Deepak 99 102 SQL
105 Diya 97 105 Computer
Networks
Natural Join
Select * from student natural join library;
Result Table
Student
Id Name Marks Id Book
102 Deepak 99 102 SQL
105 Diya 97 105 Computer
Networks