Wednesday, 22 January 2020

SQL Basics

What is CURD operation?

Insert -C
Update-U
Select -R
Delete-D


1.Creating a Table:

create table Employee (
    EmpID int,
    EmpName varchar(255),
    EmpPhNum int,
    EmpAge int,
    EmpAddress varchar(255)
);

2.Insert values into the created Table:

insert into Employee values(1,'John',989756,21,'Street 1,LF');
insert into Employee values(2,'JohnP',989757,24,'Street 2,GH');
insert into Employee values(3,'Peter',989456,27,'Street 3,CF');
insert into Employee values(3,'Peter',989456,27,'Street 3,CF');
insert into Employee values(4,'Johnson',983656,45,'Street 4,WE');
insert into Employee values(5,'Johny',989866,25,'Street 5,DF');
insert into Employee values(6,'Johny',989866,35,'Street 5,DF');

3.Read the values from the table:

select * from Employee where EmpName="Johny";
select * from Employee where EmpName="Johny" and EmpAge="35";
select * from Employee where Empage>25;

4.Select distinct values from the table:

select distinct * from Employee;
select distinct EmpName from Employee;

5.Get the count of values from the table:

select count(*) from Employee;
select count(distinct EmpName) from Employee;


No comments:

Post a Comment