0% found this document useful (0 votes)
5 views2 pages

Assignments

The document outlines SQL commands for managing databases, including creating tables for salesman, product, and sales, as well as inserting and selecting data. It also includes commands for creating a library database, managing books and members, and issuing books to members. Various SQL queries are provided to retrieve and manipulate data from these tables.

Uploaded by

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

Assignments

The document outlines SQL commands for managing databases, including creating tables for salesman, product, and sales, as well as inserting and selecting data. It also includes commands for creating a library database, managing books and members, and issuing books to members. Various SQL queries are provided to retrieve and manipulate data from these tables.

Uploaded by

vikas kakade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

show databases;

use vikas;
create table salesman(salesman_id int, salesman_name varchar(20), city
varchar(20));
insert into salesman values(25,"Raju","pune"),(24,"Kaju","Delhi");
select * from salesman;
create table product(product_id int, product_name varchar(20), price int);
insert into product values(1001,"Table",2000),(1002,"chair",3000);
create table sales(product_id int, salesman_id int, qty_sold int);
insert into sale values(1001,25,2),(1002,24,2);
/* 1 select salesman_name,city,qty_sold from salesman join sales on
salesman.salesman_id=sales.salesman_id; */
/* 2 select product_name,salesman_id,qty_sold from product left join sales on
product.product_id=sales.product_id; */
-- 3 select salesman_name,city,qty_sold from salesman left join sales on
salesman.salesman_id=sales.salesman_id where city="pune";
-- 4 select city,salesman_name from salesman join sales on
salesman.salesman_id=sales.salesman_id group by city having count(city)>=2;
-- 5 select product_name,salesman_name,qty_sold from sales join salesman on
sales.salesman_id=salesman.salesman_id join product on
sales.product_id=product.product_id where salesman_name like 'M%';
-- 6 select product_name,salesman_name,qty_sold,sum(price) from sales join salesman
on sales.salesman_id=salesman.salesman_id join product on
sales.product_id=product.product_id where salesman_name like 'M%';
-- 7 select salesman_name, city from salesman;
-- 8 select product_id, avg(price) from product;
-- 9 select substring(salesman_name,1,3) as salesman_name from salesman;
-- 10 select * from product order by product_name;
select * from salesman;
select * from product;
select * from sales;
create database library;
use libtrary;
create table book (book_id int, book_name varchar(40),author_name varchar(40),
price int);
insert into book values (25,"chadrayan","ramesh kamlbli",4000),
(26,"magalyan"," solary pandya",5000);
select * from book;
create table member (member_id int ,member_name varchar(50),address varchar(40));
insert into member values(101,"Arjun Rampal","living in mumbai"),(102,"Sachin
tedulkar","lives in bandra");
select * from member;
create table issue (book_id int,member_id int, date_of_issue date, date_of_return
date);
insert into issue values(25,101,2022-06-26,2022-07-27),(26,12,2022-06-27,2022-07-
27);
select * from issue;
update issue set date_of_issue=26/06/2022,date_of_return=26/07/2022 where
book_id=25;
use library;
update issue set date_of_issue=26/06/2022,date_of_return=26/07/2022 where
book_id=25;
use vikas;
update issue set date_of_issue=26/06/2022,date_of_return=26/07/2022 where
book_id=25;
select * from issue;
update issue set date_of_issue=2022-06-26,date_of_return=2022-07-26 where
book_id=25;
select * from issue;
update issue set date_of_issue=(26/06/2022),date_of_return=(26/07/2022) where
book_id=25;
select * from issue;
update issue set date_of_issue='26/06/2022',date_of_return='26/07/2022' where
book_id=25;
select * from issue;
update issue set date_of_issue='27/06/2022',date_of_return='27/07/2022' where
book_id=26;
select * from issue;
select book_name,date_of_issue,date_of_name from book join issue on
book.book_id=issue.book_id;

You might also like