Professional Documents
Culture Documents
Table – Table contains rows and columns, where the rows are
known as records and the column are known as fileds.
Character/String
Numbers
1- Int
2- Bigint
Studentid int,
Firstname Varchar(255),
Lastname Varchar(255),
Mockmarks int,
City varchar(255)
);
insert into
Student(Studentid,Firstname,Lastname,Mockmarks,City)
Values (1,'Vikas','Mishra',18,'Palghar');
insert into
Student(Studentid,Firstname,Lastname,Mockmarks,City)
Values (2,'Jyoti','Chavhan',16,'Amravati');
insert into
Student(Studentid,Firstname,Lastname,Mockmarks,City)
Values (3,'Amey','Kalantre',14,'Kolhapur');
insert into
Student(Studentid,Firstname,Lastname,Mockmarks,City)
Values (4,'Yogesh','Nangare',19,'Ahmednagar');
insert into
Student(Studentid,Firstname,Lastname,Mockmarks,City)
Values (5,'Prajakta','Tidar',17,'Satara');
insert into
Student(Studentid,Firstname,Lastname,Mockmarks,City)
Values (6,'Rohini','Kole',19,'Sangali');
Arithmetic Operators
Comparison Operators
1- Equal to (=)
The = symbol is used to filter results that equals to a certain
value.
Syntax- Select * from TN where CN=value;
Select * from Student where mockmarks=18;
2- Not Equal to (!=)
The != symbol is used to filter results that do not equals to a
certain value.
Syntax- Select * from TN where CN!=value;
Select * from Student where mockmarks!=18;
Like Operator
Between Operator
In operator
Distinct Keyword
TOP/Limit/Rownum
Order By Clause
It is used to sort the records in your result set in ascending and
descending order.
Aggregate Functions
Group by
Having clause
Note – The having clause was added to SQL because the where
keyword cannot be used with aggregate functions.
SQL Constraints
Types of constraints
1- Not null
2- Unique
3- Primary Key
4- Foreign key
5- Check constraint
6- Default constraints
Not Null – It does not allow the user to insert null value. If we
want to make any field as mandatory then we will use not null
constraint.
Studentid int,
Orderid int,
Oname Varchar(255),
);
Firstname Varchar(255),
Lastname Varchar(255),
Mockmarks int,
City varchar(255)
);
insert into
Student(Studentid,Firstname,Lastname,Mockmarks,City)
Values (1,'Vikas','Mishra',18,'Palghar');
insert into
Student(Studentid,Firstname,Lastname,Mockmarks,City)
Values (2,'Jyoti','Chavhan',16,'Amravati');
insert into
Student(Studentid,Firstname,Lastname,Mockmarks,City)
Values (3,'Amey','Kalantre',14,'Kolhapur');
insert into
Student(Studentid,Firstname,Lastname,Mockmarks,City)
Values (4,'Yogesh','Nangare',19,'Ahmednagar');
insert into
Student(Studentid,Firstname,Lastname,Mockmarks,City)
Values (5,'Prajakta','Tidar',17,'Satara');
insert into
Student(Studentid,Firstname,Lastname,Mockmarks,City)
Values (6,'Rohini','Kole',19,'Sangali');
Oname Varchar(255),
);
Values (1778,'Iphone',4);
Values (1767,6);
Values (1654,'NoKia',1);
Values (1743,'Readme',6);
Values (1900,'Vivo',10);
Check Constraint
Default constraint
Studentid int,
Firstname Varchar(255),
Lastname Varchar(255),
Union
Select * from TN1 Union Select * from TN2 (Note – SQL has strict
rule that both the tables must have same number of Columns)
Union All
It allows duplicate values and it combines all the data from both
the tables.
Types of Joins
1- Inner Join
2- Left join
3- Right join
4- Full Join
Right Join - It returns all records from Right table and matching
records from left table.
Full Join – It returns all the records from both the table.
Interview Questions
5- Joins In SQL?
6- Constraints In SQL?
7- Aggregate Functions?
8- Different Types of SQL commands?
9- Difference between Drop, Truncate and delete
10- Difference Between Union and Union all?
11- Different Operators In SQl?
12- Different clauses in SQL?
The END