SQL Queries to create table Customer and table Order.

Q.1 Create a database Product.

Solution :- 

create database product;

Q.2 Access Database

Solution :- 

use product;

Q.3(a) Create table Customer.

Solution :- 

create table customer
(
CustomerID int primary key,
CustomerName varchar(100),
City varchar(100),
Age varchar(100),
Phone int);

Q.3(b) Create table Order.

Solution :- 

CREATE TABLE Order (
ProjectID INT PRIMARY KEY,
ProjectName VARCHAR(50),
EmployeeID INT, foreign key(EmployeeID) references customer(EmployeeID),
Budget DECIMAL(10, 2)
);

Q.4(a) Insert into table customer. 

Solution :- 

insert into customer values(1,”Alice Johnson”,”New York”,28,123456789);
insert into customer values(2,”Bob Smith”,”Los Angeles”,35,987654321);
insert into customer values(3,”Charlie Brown”,”Chicago”,30,456789123);
insert into customer values(4,”Diana Prince”,”Houston”,40,789012345);
insert into customer values(5,”Edward Wilson”,”Phoenix”,25,321654987);

Q.4(b) Insert into table Orders. 

Solution  :- 

insert into orders values(101,’2025-01-01′,1,500);
insert into orders values(102,’2025-01-03′,2,1000);
insert into orders values(103,’2025-01-05′,3,700);
insert into orders values(104,’2025-01-10′,4,1200);
insert into orders values(105,’2025-01-12′,5,300);

Q.5 Display all records from the Customers table. Whose age more than 30 years.

Solution :- 

SELECT * FROM Customer WHERE Age > 30;

Q.6 Change the phone number of customer id 2 to 555666777. 

Solution  :- 

UPDATE Customer SET Phone = ‘555666777’WHERE CustomerID = 2;

Q.7 Display OrderID, OrderDate , customerName and Phone from the table.

Solution :- 

SELECT Orders.OrderID, Orders.OrderDate, Customer.CustomerName, Customer.Phone FROM Orders JOIN Customer ON Orders.CustomerID = Customer.CustomerID;

Q.8 Display all orders placed after 2025-01-05.

Solution :- 

SELECT * FROM Orders WHERE OrderDate > ‘2025-01-05’;

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.