BASE Queries
BASE Queries
BASE Queries
Note: Whenever you write queries all the field names (EmpID, EmpName, DOB, City, Salary) are
case sensitive.
Ans:
CREATE TABLE Employee
(
EmpID Integer PRIMARY KEY,
EmpName Varchar(30),
DOB date NOT NULL,
City Varchar(20) DEFAULT 'Surat',
Salary Decimal,
UNIQUE(EmpName),
CHECK(Salary>30000)
)
DESC Employee
OR
DESCRIBE Employee
SELECT *
FROM Employee
SELECT *
FROM Employee
WHERE EmpName='Ritu'
SELECT *
FROM Employee
WHERE DOB>'2005-12-25'
9. Display all the records whose City is 'Mumbai' and Salary is less than or equal 40000.
SELECT *
FROM Employee
WHERE City='Mumbai' and Salary<=40000
10. Display all the records whose City is 'Mumbai' or Salary is less than or equal 40000.
SELECT *
FROM Employee
WHERE City='Mumbai' or Salary<=40000
11. Display all the unique cities from City field.
SELECT DISTINCT(City)
FROM Employee
SELECT ALL(City)
FROM Employee
13. Give 10% bonus to all the employee and display EmpName, Salary, Bonus, Total
Salary(Salary+Bonus).
14. Display the details of all those employees whose salary between 45000 to 55000.
SELECT *
FROM Employee
WHERE Salary BETWEEN 45000 AND 55000
15. Display the details of all those employees who are staying in Surat or Mumbai city.
SELECT *
FROM Employee
WHERE City IN('Surat','Mumbai')
OR
SELECT *
FROM Employee
WHERE City='Surat' OR City='Mumbai'
16. Display the details of all those employees who are not staying in Surat or Mumbai city.
SELECT *
FROM Employee
WHERE City NOT IN('Surat','Mumbai')
17. Display the details of all those employees whose name start with H character.
SELECT *
FROM Employee
WHERE EmpName LIKE 'H%'
18. Display the details of all those employees whose name end with H character.
SELECT *
FROM Employee
WHERE EmpName LIKE '%h'
19. Display the details of all those employees whose Salary contain NULL.
SELECT *
FROM Employee
WHERE Salary IS NULL
UPDATE Employee
SET EmpName='Sagar'
WHERE EmpID=104
UPDATE Employee
SET Salary=Salary+3000
DELETE
FROM Employee
WHERE EmpID=106
DELETE
FROM Employee
25. Create two tables named Customer (CustID, Name) and Orders (OrderID, OrderDate,
CustID, Amount).
26. Make CustID as Primary key in Customer table and OrderID as Primary key in Orders table.
31. Insert the details of those branches into branch1 whose gross is greater than 7000 in
branch2.
SELECT curdate()
SELECT 3.14*6*6
SELECT (10000*5.5*2)/100
SELECT 10*10
SELECT 10*10*10