0% found this document useful (0 votes)
3 views4 pages

Manaham Lab Task Database

The document outlines a database lab task involving the creation and manipulation of an 'Employee' table. It includes SQL commands for creating the table, inserting records, and various queries to display employee data based on specific criteria. The tasks cover displaying all records, unique departments, filtering by city and salary, and inserting additional employee records.

Uploaded by

Bishamith Faith
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Manaham Lab Task Database

The document outlines a database lab task involving the creation and manipulation of an 'Employee' table. It includes SQL commands for creating the table, inserting records, and various queries to display employee data based on specific criteria. The tasks cover displaying all records, unique departments, filtering by city and salary, and inserting additional employee records.

Uploaded by

Bishamith Faith
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

DATABASE LAB

LAB TASK
1. Create Table:
DROP TABLE IF EXISTS Employee;

CREATE TABLE Employee (


id INT PRIMARY KEY,
name VARCHAR(20),
Department VARCHAR(50),
city VARCHAR(50),
salary INT
);

INSERT INTO Employee VALUES (1,'Ali','CS','Lahore',50000);


INSERT INTO Employee VALUES (2,'Izza','SE','Karachi',48000);
INSERT INTO Employee VALUES (3,'Sara','SE','Islamabad',75000);
INSERT INTO Employee VALUES (4,'Ahmad','CS','Multan',52000);
INSERT INTO Employee VALUES (5,'Zain','SE','Rawalpindi',47000);
INSERT INTO Employee VALUES (6,'Ayesha','CS','Lahore',55000);
INSERT INTO Employee VALUES (7,'Fatima','SE','Sialkot',49000);
INSERT INTO Employee VALUES (8,'Sam','CS','Faisalabad',60000);
INSERT INTO Employee VALUES (9,'Saleha','SE','Lahore',65000);
INSERT INTO Employee VALUES (10,'Hassan','CS','Karachi',62000);
INSERT INTO Employee VALUES (11,'Noor','SE','Peshawar',70000);
INSERT INTO Employee VALUES (12,'Asna','CS','Quetta',45000);
INSERT INTO Employee VALUES (13,'Umar','SE','Hyderabad',88000);
INSERT INTO Employee VALUES (14,'Iqra','CS','Sukkur',49000);
INSERT INTO Employee VALUES (15,'Bilal','SE','Multan',53000);

[Link] ALL records:

SELECT * FROM Employee;

[Link] Unique departments:

SELECT DISTINCT Department FROM Employee;

[Link] Employees From Lahore:

SELECT * FROM Employee WHERE city = 'Lahore';

[Link] salaray greater than 55000:

SELECT * FROM Employee WHERE salary > 55000;

[Link] 2 employees with different cities and salaraies:

INSERT INTO Employee VALUES (8,'izz','CS','uk',99000);


INSERT INTO Employee VALUES (9,'umar','SE','korea',88000);

[Link] employee from CS living in Karachi:


SELECT * FROM Employee
WHERE Department = 'CS' AND city = 'Karachi';

[Link] not from Lahore:

SELECT * FROM Employee WHERE city <> 'Lahore';

Output:

DEPARTMENT:

Employees From Lahore:


Salaray greater than 55000

Karachi

Not From Lahore

You might also like