Sei sulla pagina 1di 22

DATABASE MANAGEMENT PRACTICAL FILE

AYUSHI VERMA 7043 BMS(2nd SEM)

Q.1
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.62 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database library;


ERROR 1007 (HY000): Can't create database 'library'; database exists
mysql> use database library;
ERROR 1049 (42000): Unknown database 'database'
mysql> use library;
Database changed
mysql> create table libbooks(accesion_no int primary key, title char(20), author
char(30), dept char(20), purchase_date date, price int);
Query OK, 0 rows affected (0.39 sec)

mysql> create table issuedbooks(accesion_no int,borrower char(20),foreign


key(accesion_no) references libbooks;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 1
mysql> create table issuedbooks(accesion_no int,borrower char(20),foreign
key(accesion_no) references libbooks(accesion_no);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 1
mysql> create table issuedbooks(accesion_no int,borrower char(20),foreign
key(accesion_no) references libbooks(accesion_no));
Query OK, 0 rows affected (0.14 sec)

mysql> insert into libbooks values(1,'microeconomics','abc','2000:01:01',500);


ERROR 1136 (21S01): Column count doesn't match value count at row 1
mysql> insert into libbooks
values(1,'microeconomics','abc','commerce','2000:01:01',500);
Query OK, 1 row affected (0.05 sec)

mysql> insert into libbooks values(2,'database system


concept','bayross','cs','2002:12:01',300);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'insert
into libbooks values(2,'database system concept','bayross','cs','2002:12:' at line
2
mysql> insert into libbooks values(2,'database system
concept','bayross','cs','2002:12:01',300);
ERROR 1406 (22001): Data too long for column 'title' at row 1
mysql> insert into libbooks values(2,'database
system','bayross','cs','2002:12:01',300);
Query OK, 1 row affected (0.05 sec)
mysql> INSERT INTO libbooks values('3','algebra','xyz','discrete
maths','2002:06:09');
ERROR 1136 (21S01): Column count doesn't match value count at row 1
mysql> INSERT INTO libbooks values('3','algebra','xyz','discrete
maths','2002:06:09',300);
Query OK, 1 row affected (0.06 sec)

mysql> INSERT INTO libbooks


values('4','literature','lmn','english','2007:06:09',600);
Query OK, 1 row affected (0.03 sec)

mysql> select * from libboks;


ERROR 1146 (42S02): Table 'library.libboks' doesn't exist
mysql> select * from libbooks;
+-------------+-----------------+---------+----------------+---------------+-------
+
| accesion_no | title | author | dept | purchase_date | price
|
+-------------+-----------------+---------+----------------+---------------+-------
+
| 1 | microeconomics | abc | commerce | 2000-01-01 | 500
|
| 2 | database system | bayross | cs | 2002-12-01 | 300
|
| 3 | algebra | xyz | discrete maths | 2002-06-09 | 300
|
| 4 | literature | lmn | english | 2007-06-09 | 600
|
+-------------+-----------------+---------+----------------+---------------+-------
+
4 rows in set (0.05 sec)
mysql> insert into issuedbooks(2,'2003:09:09');
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'2,'2003:09:09')' at line 1
mysql> insert into issuedbooks values(2,'2003:09:09');
Query OK, 1 row affected (0.06 sec)

mysql> insert into issuedbooks values(3,'2004:07:23');


Query OK, 1 row affected (0.06 sec)

mysql> insert into issuedbooks values(4,'2009:03:28');


Query OK, 1 row affected (0.06 sec)

mysql> insert into issuedbooks values(1,'2001:02:21');


Query OK, 1 row affected (0.05 sec)

mysql> select * from issuedbooks;


+-------------+------------+
| accesion_no | borrower |
+-------------+------------+
| 2 | 2003:09:09 |
| 3 | 2004:07:23 |
| 4 | 2009:03:28 |
| 1 | 2001:02:21 |
+-------------+------------+
4 rows in set (0.02 sec)

mysql> delete * from issuedbooks;


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '* from
issuedbooks' at line 1
mysql> update issuedbooks set borrower='ayushi' where acession_no=2;
ERROR 1054 (42S22): Unknown column 'acession_no' in 'where clause'
mysql> update issuedbooks set borrower='ayushi' where accession_no=2;
ERROR 1054 (42S22): Unknown column 'accession_no' in 'where clause'
mysql> update issuedbooks set borrower='ayushi' where accesion_no=2;
Query OK, 1 row affected (0.08 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> update issuedbooks set borrower='mamta' where accesion_no=3;


Query OK, 1 row affected (0.23 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> update issuedbooks set borrower='lovely' where accesion_no=4;


Query OK, 1 row affected (0.06 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> update issuedbooks set borrower='himanshi' where accesion_no=1;


Query OK, 1 row affected (0.05 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from issuedbooks;


+-------------+----------+
| accesion_no | borrower |
+-------------+----------+
| 2 | ayushi |
| 3 | mamta |
| 4 | lovely |
| 1 | himanshi |
+-------------+----------+
4 rows in set (0.00 sec)

mysql> delete from libbooks where title='database concepts';


Query OK, 0 rows affected (0.00 sec)

mysql> select * from libbooks;


+-------------+-----------------+---------+----------------+---------------+-------
+
| accesion_no | title | author | dept | purchase_date | price
|
+-------------+-----------------+---------+----------------+---------------+-------
+
| 1 | microeconomics | abc | commerce | 2000-01-01 | 500
|
| 2 | database system | bayross | cs | 2002-12-01 | 300
|
| 3 | algebra | xyz | discrete maths | 2002-06-09 | 300
|
| 4 | literature | lmn | english | 2007-06-09 | 600
|
+-------------+-----------------+---------+----------------+---------------+-------
+
4 rows in set (0.00 sec)

mysql> delete from libbooks where title='database system';


ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint
fails (`library`.`issuedbooks`, CONSTRAINT `issuedbooks_ibfk_1` FOREIGN KEY
(`accesion_no`) REFERENCES `libbooks` (`accesion_no`))
mysql> delete from libbooks where title='database system';
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint
fails (`library`.`issuedbooks`, CONSTRAINT `issuedbooks_ibfk_1` FOREIGN KEY
(`accesion_no`) REFERENCES `libbooks` (`accesion_no`))
mysql> update libbooks set dept='cs' where dept='discrete maths';
Query OK, 1 row affected (0.06 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from libboks where dept='cs';


ERROR 1146 (42S02): Table 'library.libboks' doesn't exist
mysql> select * from libbooks where dept='cs';
+-------------+-----------------+---------+------+---------------+-------+
| accesion_no | title | author | dept | purchase_date | price |
+-------------+-----------------+---------+------+---------------+-------+
| 2 | database system | bayross | cs | 2002-12-01 | 300 |
| 3 | algebra | xyz | cs | 2002-06-09 | 300 |
+-------------+-----------------+---------+------+---------------+-------+
2 rows in set (0.00 sec)

mysql> select * from libbooks where dept='cs' and author='bayross';


+-------------+-----------------+---------+------+---------------+-------+
| accesion_no | title | author | dept | purchase_date | price |
+-------------+-----------------+---------+------+---------------+-------+
| 2 | database system | bayross | cs | 2002-12-01 | 300 |
+-------------+-----------------+---------+------+---------------+-------+
1 row in set (0.00 sec)

mysql> select * from issuedbooks,libooks where dept='cs';


ERROR 1146 (42S02): Table 'library.libooks' doesn't exist
mysql> select * from issuedbooks,libbooks where dept='cs';
+-------------+----------+-------------+-----------------+---------+------
+---------------+-------+
| accesion_no | borrower | accesion_no | title | author | dept |
purchase_date | price |
+-------------+----------+-------------+-----------------+---------+------
+---------------+-------+
| 2 | ayushi | 2 | database system | bayross | cs | 2002-
12-01 | 300 |
| 3 | mamta | 2 | database system | bayross | cs | 2002-
12-01 | 300 |
| 4 | lovely | 2 | database system | bayross | cs | 2002-
12-01 | 300 |
| 1 | himanshi | 2 | database system | bayross | cs | 2002-
12-01 | 300 |
| 2 | ayushi | 3 | algebra | xyz | cs | 2002-
06-09 | 300 |
| 3 | mamta | 3 | algebra | xyz | cs | 2002-
06-09 | 300 |
| 4 | lovely | 3 | algebra | xyz | cs | 2002-
06-09 | 300 |
| 1 | himanshi | 3 | algebra | xyz | cs | 2002-
06-09 | 300 |
+-------------+----------+-------------+-----------------+---------+------
+---------------+-------+
8 rows in set (0.00 sec)

mysql> select * from libbooks where price<500 and purchase_date between


'1999:01:01' and '2004:01:01';
+-------------+-----------------+---------+------+---------------+-------+
| accesion_no | title | author | dept | purchase_date | price |
+-------------+-----------------+---------+------+---------------+-------+
| 2 | database system | bayross | cs | 2002-12-01 | 300 |
| 3 | algebra | xyz | cs | 2002-06-09 | 300 |
+-------------+-----------------+---------+------+---------------+-------+
2 rows in set (0.03 sec)

question 2
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.62 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database library;


ERROR 1007 (HY000): Can't create database 'library'; database exists
mysql> use database library;
ERROR 1049 (42000): Unknown database 'database'
mysql> use library;
Database changed
mysql> create table libbooks(accesion_no int primary key, title char(20), author
char(30), dept char(20), purchase_date date, price int);
Query OK, 0 rows affected (0.39 sec)

mysql> create table issuedbooks(accesion_no int,borrower char(20),foreign


key(accesion_no) references libbooks;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 1
mysql> create table issuedbooks(accesion_no int,borrower char(20),foreign
key(accesion_no) references libbooks(accesion_no);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 1
mysql> create table issuedbooks(accesion_no int,borrower char(20),foreign
key(accesion_no) references libbooks(accesion_no));
Query OK, 0 rows affected (0.14 sec)

mysql> insert into libbooks values(1,'microeconomics','abc','2000:01:01',500);


ERROR 1136 (21S01): Column count doesn't match value count at row 1
mysql> insert into libbooks
values(1,'microeconomics','abc','commerce','2000:01:01',500);
Query OK, 1 row affected (0.05 sec)

mysql> insert into libbooks values(2,'database system


concept','bayross','cs','2002:12:01',300)
-> insert into libbooks values(2,'database system
concept','bayross','cs','2002:12:01',300)
->
-> insert into libbooks values(2,'database system
concept','bayross','cs','2002:12:01',300);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'insert
into libbooks values(2,'database system concept','bayross','cs','2002:12:' at line
2
mysql> insert into libbooks values(2,'database system
concept','bayross','cs','2002:12:01',300);
ERROR 1406 (22001): Data too long for column 'title' at row 1
mysql> insert into libbooks values(2,'database
system','bayross','cs','2002:12:01',300);
Query OK, 1 row affected (0.05 sec)

mysql> INSERT INTO libbooks values('3','algebra','xyz','discrete


maths','2002:06:09');
ERROR 1136 (21S01): Column count doesn't match value count at row 1
mysql> INSERT INTO libbooks values('3','algebra','xyz','discrete
maths','2002:06:09',300);
Query OK, 1 row affected (0.06 sec)

mysql> INSERT INTO libbooks


values('4','literature','lmn','english','2007:06:09',600);
Query OK, 1 row affected (0.03 sec)

mysql> select * from libboks;


ERROR 1146 (42S02): Table 'library.libboks' doesn't exist
mysql> select * from libbooks;
+-------------+-----------------+---------+----------------+---------------+-------
+
| accesion_no | title | author | dept | purchase_date | price
|
+-------------+-----------------+---------+----------------+---------------+-------
+
| 1 | microeconomics | abc | commerce | 2000-01-01 | 500
|
| 2 | database system | bayross | cs | 2002-12-01 | 300
|
| 3 | algebra | xyz | discrete maths | 2002-06-09 | 300
|
| 4 | literature | lmn | english | 2007-06-09 | 600
|
+-------------+-----------------+---------+----------------+---------------+-------
+
4 rows in set (0.05 sec)

mysql> insert into issuedbooks(2,'2003:09:09');


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'2,'2003:09:09')' at line 1
mysql> insert into issuedbooks values(2,'2003:09:09');
Query OK, 1 row affected (0.06 sec)

mysql> insert into issuedbooks values(3,'2004:07:23');


Query OK, 1 row affected (0.06 sec)

mysql> insert into issuedbooks values(4,'2009:03:28');


Query OK, 1 row affected (0.06 sec)

mysql> insert into issuedbooks values(1,'2001:02:21');


Query OK, 1 row affected (0.05 sec)
mysql> select * from issuedbooks;
+-------------+------------+
| accesion_no | borrower |
+-------------+------------+
| 2 | 2003:09:09 |
| 3 | 2004:07:23 |
| 4 | 2009:03:28 |
| 1 | 2001:02:21 |
+-------------+------------+
4 rows in set (0.02 sec)

mysql> delete * from issuedbooks;


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '* from
issuedbooks' at line 1
mysql> update issuedbooks set borrower='ayushi' where acession_no=2;
ERROR 1054 (42S22): Unknown column 'acession_no' in 'where clause'
mysql> update issuedbooks set borrower='ayushi' where accession_no=2;
ERROR 1054 (42S22): Unknown column 'accession_no' in 'where clause'
mysql> update issuedbooks set borrower='ayushi' where accesion_no=2;
Query OK, 1 row affected (0.08 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> update issuedbooks set borrower='mamta' where accesion_no=3;


Query OK, 1 row affected (0.23 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> update issuedbooks set borrower='lovely' where accesion_no=4;


Query OK, 1 row affected (0.06 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> update issuedbooks set borrower='himanshi' where accesion_no=1;


Query OK, 1 row affected (0.05 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from issuedbooks;


+-------------+----------+
| accesion_no | borrower |
+-------------+----------+
| 2 | ayushi |
| 3 | mamta |
| 4 | lovely |
| 1 | himanshi |
+-------------+----------+
4 rows in set (0.00 sec)

mysql> delete from libbooks where title='database concepts';


Query OK, 0 rows affected (0.00 sec)

mysql> select * from libbooks;


+-------------+-----------------+---------+----------------+---------------+-------
+
| accesion_no | title | author | dept | purchase_date | price
|
+-------------+-----------------+---------+----------------+---------------+-------
+
| 1 | microeconomics | abc | commerce | 2000-01-01 | 500
|
| 2 | database system | bayross | cs | 2002-12-01 | 300
|
| 3 | algebra | xyz | discrete maths | 2002-06-09 | 300
|
| 4 | literature | lmn | english | 2007-06-09 | 600
|
+-------------+-----------------+---------+----------------+---------------+-------
+
4 rows in set (0.00 sec)

mysql> delete from libbooks where title='database system';


ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint
fails (`library`.`issuedbooks`, CONSTRAINT `issuedbooks_ibfk_1` FOREIGN KEY
(`accesion_no`) REFERENCES `libbooks` (`accesion_no`))
mysql> delete from libbooks where title='database system';
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint
fails (`library`.`issuedbooks`, CONSTRAINT `issuedbooks_ibfk_1` FOREIGN KEY
(`accesion_no`) REFERENCES `libbooks` (`accesion_no`))
mysql> update libbooks set dept='cs' where dept='discrete maths';
Query OK, 1 row affected (0.06 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> select * from libboks where dept='cs';


ERROR 1146 (42S02): Table 'library.libboks' doesn't exist
mysql> select * from libbooks where dept='cs';
+-------------+-----------------+---------+------+---------------+-------+
| accesion_no | title | author | dept | purchase_date | price |
+-------------+-----------------+---------+------+---------------+-------+
| 2 | database system | bayross | cs | 2002-12-01 | 300 |
| 3 | algebra | xyz | cs | 2002-06-09 | 300 |
+-------------+-----------------+---------+------+---------------+-------+
2 rows in set (0.00 sec)

mysql> select * from libbooks where dept='cs' and author='bayross';


+-------------+-----------------+---------+------+---------------+-------+
| accesion_no | title | author | dept | purchase_date | price |
+-------------+-----------------+---------+------+---------------+-------+
| 2 | database system | bayross | cs | 2002-12-01 | 300 |
+-------------+-----------------+---------+------+---------------+-------+
1 row in set (0.00 sec)

mysql> select * from issuedbooks,libooks where dept='cs';


ERROR 1146 (42S02): Table 'library.libooks' doesn't exist
mysql> select * from issuedbooks,libbooks where dept='cs';
+-------------+----------+-------------+-----------------+---------+------
+---------------+-------+
| accesion_no | borrower | accesion_no | title | author | dept |
purchase_date | price |
+-------------+----------+-------------+-----------------+---------+------
+---------------+-------+
| 2 | ayushi | 2 | database system | bayross | cs | 2002-
12-01 | 300 |
| 3 | mamta | 2 | database system | bayross | cs | 2002-
12-01 | 300 |
| 4 | lovely | 2 | database system | bayross | cs | 2002-
12-01 | 300 |
| 1 | himanshi | 2 | database system | bayross | cs | 2002-
12-01 | 300 |
| 2 | ayushi | 3 | algebra | xyz | cs | 2002-
06-09 | 300 |
| 3 | mamta | 3 | algebra | xyz | cs | 2002-
06-09 | 300 |
| 4 | lovely | 3 | algebra | xyz | cs | 2002-
06-09 | 300 |
| 1 | himanshi | 3 | algebra | xyz | cs | 2002-
06-09 | 300 |
+-------------+----------+-------------+-----------------+---------+------
+---------------+-------+
8 rows in set (0.00 sec)

mysql> select * from libbooks where price<500 and purchase_date between


'1999:01:01' and '2004:01:01';
+-------------+-----------------+---------+------+---------------+-------+
| accesion_no | title | author | dept | purchase_date | price |
+-------------+-----------------+---------+------+---------------+-------+
| 2 | database system | bayross | cs | 2002-12-01 | 300 |
| 3 | algebra | xyz | cs | 2002-06-09 | 300 |
+-------------+-----------------+---------+------+---------------+-------+
2 rows in set (0.03 sec)

mysql> select * from issuedbooks,libbooks where dept='cs';


+-------------+----------+-------------+-----------------+---------+------
+---------------+-------+
| accesion_no | borrower | accesion_no | title | author | dept |
purchase_date | price |
+-------------+----------+-------------+-----------------+---------+------
+---------------+-------+
| 2 | ayushi | 2 | database system | bayross | cs | 2002-
12-01 | 300 |
| 3 | mamta | 2 | database system | bayross | cs | 2002-
12-01 | 300 |
| 4 | lovely | 2 | database system | bayross | cs | 2002-
12-01 | 300 |
| 1 | himanshi | 2 | database system | bayross | cs | 2002-
12-01 | 300 |
| 2 | ayushi | 3 | algebra | xyz | cs | 2002-
06-09 | 300 |
| 3 | mamta | 3 | algebra | xyz | cs | 2002-
06-09 | 300 |
| 4 | lovely | 3 | algebra | xyz | cs | 2002-
06-09 | 300 |
| 1 | himanshi | 3 | algebra | xyz | cs | 2002-
06-09 | 300 |
+-------------+----------+-------------+-----------------+---------+------
+---------------+-------+
8 rows in set (0.00 sec)

mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql> create database computer_deptartment;
Query OK, 1 row affected (0.00 sec)

mysql> use computer_deptartment;


Database changed
mysql> create table studentinfo(rollno int primary key,name char(30),dob
date,address char(40),marks int,phoneno int;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 1
mysql> create table studentinfo(rollno int primary key,name char(30),dob
date,address char(40),marks int,phoneno int);
Query OK, 0 rows affected (0.11 sec)

mysql> create table paperdetails(papercode int primary key,papername char(20);


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 1
mysql> create table paperdetails(papercode int primary key,papername char(20));
Query OK, 0 rows affected (0.14 sec)

mysql> create table academicdetail(rollno int,papercode int,attendance int,marks


int,foreign key (rollno) references studentinfo(rollno),foreign key(papercode)
references paperdetails (papercode));
Query OK, 0 rows affected (0.16 sec)

mysql> alter table academicdetail add constraint primary key(rollno,papercode);


Query OK, 0 rows affected (0.27 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> insert into studentinfo values (1,'ayushi','2000:06:07','almora',90,12345);


Query OK, 1 row affected (0.06 sec)

mysql> insert into studentinfo values


(2,'asmita','2000:12:09','aligarh',80,123456);
Query OK, 1 row affected (0.05 sec)

mysql> insert into studentinfo values (3,'prateek','2000:10:23','mumbai',85,93456);


Query OK, 1 row affected (0.06 sec)

mysql> insert into studentinfo values (4,'ritu','2000:09:16','delhi',85,98956);


Query OK, 1 row affected (0.06 sec)

mysql> insert into paperdetails values (10,'microeco');


Query OK, 1 row affected (0.06 sec)

mysql> insert into paperdetails values (20,'b.accounting');


Query OK, 1 row affected (0.06 sec)

mysql> insert into paperdetails values (30,'b.communication');


Query OK, 1 row affected (0.06 sec)

mysql> insert into paperdetails values (40,'stock market');


Query OK, 1 row affected (0.05 sec)

mysql> insert into academicdetail values(1,10,78,90);


Query OK, 1 row affected (0.06 sec)

mysql> insert into academicdetail values(1,20,80,89);


Query OK, 1 row affected (0.05 sec)

mysql> insert into academicdetail values(1,30,70,89);


Query OK, 1 row affected (0.06 sec)

mysql> insert into academicdetail values(1,40,68,69);


Query OK, 1 row affected (0.27 sec)

mysql> insert into academicdetail values(2,10,68,69);


Query OK, 1 row affected (0.06 sec)

mysql> insert into academicdetail values(2,20,80,34);


Query OK, 1 row affected (0.06 sec)

mysql> insert into academicdetail values(2,0,0,0);


ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint
fails (`computer_deptartment`.`academicdetail`, CONSTRAINT `academicdetail_ibfk_2`
FOREIGN KEY (`papercode`) REFERENCES `paperdetails` (`papercode`))
mysql> insert into academicdetail values(2,30,0,0);
Query OK, 1 row affected (0.06 sec)

mysql> insert into academicdetail values(2,40,70,30);


Query OK, 1 row affected (0.06 sec)

mysql> insert into academicdetail values(3,40,70,30);


Query OK, 1 row affected (0.05 sec)

mysql> insert into academicdetail values(3,30,60,70);


Query OK, 1 row affected (0.03 sec)

mysql> insert into academicdetail values(3,20,80,90);


Query OK, 1 row affected (0.06 sec)

mysql> insert into academicdetail values(4,10,70,45);


Query OK, 1 row affected (0.05 sec)
mysql> insert into academicdetail values(3,10,70,45);
Query OK, 1 row affected (0.06 sec)

mysql> insert into academicdetail values(4,20,80,95);


Query OK, 1 row affected (0.06 sec)

mysql> insert into academicdetail values(4,30,60,75);


Query OK, 1 row affected (0.05 sec)

mysql> insert into academicdetail values(4,40,70,85);


Query OK, 1 row affected (0.05 sec)

mysql> select rollno,sum(attendance),sum(marks) from academicdetail groupby rollno;


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'rollno'
at line 1
mysql> select rollno,sum(attendance),sum(marks) from academicdetail group by
rollno;
+--------+-----------------+------------+
| rollno | sum(attendance) | sum(marks) |
+--------+-----------------+------------+
| 1 | 296 | 337 |
| 2 | 218 | 133 |
| 3 | 280 | 235 |
| 4 | 280 | 300 |
+--------+-----------------+------------+
4 rows in set (0.05 sec)

mysql> select name from studentinfo,academicdetail where


studentinfo.rollno=academicdetail.rollno and papercode=20;
+---------+
| name |
+---------+
| ayushi |
| asmita |
| prateek |
| ritu |
+---------+
4 rows in set (0.00 sec)

mysql> select * from studentinfo a,academicdetail b where a.rollno=b.rollno and


address='delhi' and b.marks>60 and papercode=10;
Empty set (0.00 sec)

mysql> select * from studentinfo a,academicdetail b where a.rollno=b.rollno and


address='delhi' and b.marks>60 and papercode=20;
+--------+------+------------+---------+-------+---------+--------+-----------
+------------+-------+
| rollno | name | dob | address | marks | phoneno | rollno | papercode |
attendance | marks |
+--------+------+------------+---------+-------+---------+--------+-----------
+------------+-------+
| 4 | ritu | 2000-09-16 | delhi | 85 | 98956 | 4 | 20 |
80 | 95 |
+--------+------+------------+---------+-------+---------+--------+-----------
+------------+-------+
1 row in set (0.00 sec)
mysql> select name,max(academicdetail.marks) from studentinfo,academicdetail where
studentinfo.rollno=academicdetail.rollno and papercode=20;
+--------+---------------------------+
| name | max(academicdetail.marks) |
+--------+---------------------------+
| ayushi | 95 |
+--------+---------------------------+
1 row in set (0.00 sec)

QUESTION 3
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.77-community-nt MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database bicycles;


Query OK, 1 row affected (0.00 sec)

mysql> use bicycles;


Database changed
mysql> create table customer(CustId varchar(30) primary key,email varchar(30),name
varchar(30),phone long,RefId varchar(30));
Query OK, 0 rows affected (0.10 sec)

mysql> create table bicyclemodel(Modelno varchar(30) primary key,manufacturer


varchar(30),style varchar(30));
Query OK, 0 rows affected (0.09 sec)

mysql> create table bicycle(BicyleId varchar(30) primary key,date_purchased


date,Modelno varchar(30),color varchar(30),CustId varchar(30),foreign key(CustId)
references customer(CustId),foreign key(ModelNo) references bicyclemodel(Modelno));
Query OK, 0 rows affected (0.11 sec)

mysql> create table service(startdate date,BicyleId varchar(30),enddate


date,foreign key(BicyleId) references bicycle(BicyleId));
Query OK, 0 rows affected (0.05 sec)

mysql> insert into customer values('a1','abhi@gmail.com','abhi','6392573150','h1');


Query OK, 1 row affected (0.03 sec)

mysql> insert into customer


values('a2','ayushi@gmail.com','ayushi','33673443150','h2');
Query OK, 1 row affected (0.03 sec)

mysql> insert into customer


values('a3','deepu@gmail.com','deepu','3987663150','h3');
Query OK, 1 row affected (0.02 sec)

mysql> insert into customer


values('a4','lovely@gmail.com','lovely','99877663150','h4');
Query OK, 1 row affected (0.02 sec)

mysql> insert into customer


values('a5','mamta@gmail.com','mamta','5777663150','h5');
Query OK, 1 row affected (0.02 sec)

mysql> insert into bicyclemodel values('model1','hero','style1');


Query OK, 1 row affected (0.03 sec)

mysql> insert into bicyclemodel values('model2','honda','style2');


Query OK, 1 row affected (0.03 sec)

mysql> insert into bicyclemodel values('model3','tryst','style3');


Query OK, 1 row affected (0.03 sec)

mysql> insert into bicyclemodel values('model4','cognito','style4');


Query OK, 1 row affected (0.03 sec)

mysql> insert into bicyclemodel values('model5','lavan','style5');


Query OK, 1 row affected (0.03 sec)

mysql> insert into bicycle values('b1','2017:04:21','model1','red','c1');


Query OK, 1 row affected (0.04 sec)

mysql> insert into bicycle values('b2','2016:08:28','model2','yellow','c2');


Query OK, 1 row affected (0.03 sec)

mysql> insert into bicycle values('b3','2017:11:03','model3','black','c3');


Query OK, 1 row affected (0.01 sec)

mysql> insert into bicycle values('b4','2018:11:03','model4','blue','c4');


Query OK, 1 row affected (0.02 sec)

mysql> insert into bicycle values('b5','2017:01:08','model5','pink','c5');


Query OK, 1 row affected (0.02 sec)

mysql> insert into service values('2018:01:22','b1','2018:01:24');


Query OK, 1 row affected (0.03 sec)

mysql> insert into service values('2018:07:22','b3','2018:07:24');


Query OK, 1 row affected (0.02 sec)

mysql> insert into service values('2018:06:30','b1','2018:07:04');


Query OK, 1 row affected (0.02 sec)

mysql> insert into service values('2017:04:30','b5','2017:05:04');


Query OK, 1 row affected (0.05 sec)

mysql> insert into service values('2019:04:30','b5','2019:05:04');


Query OK, 1 row affected (0.03 sec)

mysql> select * from customer;


+--------+--------------------+----------+-------------+-------+
| CustId | email | name | phone | RefId |
+--------+--------------------+----------+-------------+-------+
| a1 | abhi@gmail.com | abhi | 6392573150 | h1 |
| a2 | ayushi@gmail.com | ayushi | 33673443150 | h2 |
| a3 | deepu@gmail.com | deepu | 3987663150 | h3 |
| a4 | lovely@gmail.com | lovely | 99877663150 | h4 |
| a5 | mamta@gmail.com | mamta | 5777663150 | h5 |
+--------+--------------------+----------+-------------+-------+
5 rows in set (0.00 sec)
mysql> select * from bicyclemodel;
+---------+--------------+--------+
| Modelno | manufacturer | style |
+---------+--------------+--------+
| model1 | hero | style1 |
| model2 | honda | style2 |
| model3 | tryst | style3 |
| model4 | cognito | style4 |
| model5 | lavan | style5 |
+---------+--------------+--------+
5 rows in set (0.00 sec)

mysql> select * from bicycle;


+----------+----------------+---------+--------+--------+
| BicyleId | date_purchased | Modelno | color | CustId |
+----------+----------------+---------+--------+--------+
| b1 | 2017-04-21 | model1 | red | a1 |
| b2 | 2016-08-28 | model2 | yellow | a2 |
| b3 | 2017-11-03 | model3 | black | a3 |
| b4 | 2018-11-03 | model4 | blue | a4 |
| b5 | 2017-01-08 | model5 | pink | a5 |
+----------+----------------+---------+--------+--------+
5 rows in set (0.00 sec)

mysql> select * from service;


+------------+----------+------------+
| startdate | BicyleId | enddate |
+------------+----------+------------+
| 2018-01-22 | b1 | 2018-01-24 |
| 2018-07-22 | b3 | 2018-07-24 |
| 2018-06-30 | b1 | 2018-07-04 |
| 2017-04-30 | b5 | 2017-05-04 |
| 2019-04-30 | b5 | 2019-05-04 |
+------------+----------+------------+
5 rows in set (0.00 sec)

mysql> select CustId from bicycle inner join bicyclemodel on


bicycle.Modelno=bicyclemodel.Modelno where manufacturer='honda';
+--------+
| CustId |
+--------+
| a2 |
+--------+
1 row in set (0.02 sec)

mysql> select BicyleId from bicycle inner join customer on


bicycle.CustId=customer.CustId where RefId='h1';
+----------+
| BicyleId |
+----------+
| b1 |
+----------+
1 row in set (0.00 sec)

mysql> select manufacturer from bicycle inner join bicyclemodel on


bicycle.Modelno=bicyclemodel.Modelno where color='red';
+--------------+
| manufacturer |
+--------------+
| hero |
+--------------+
1 row in set (0.00 sec)

mysql> select bicycle.Modelno from bicycle inner join bicyclemodel on


bicycle.Modelno=bicyclemodel.Modelno
-> inner join service on bicycle.BicyleId=service.BicyleId;
+---------+
| Modelno |
+---------+
| model1 |
| model1 |
| model3 |
| model5 |
| model5 |
+---------+
5 rows in set (0.00 sec)
QUESTION 4

Enter password: ****


Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.77-community-nt MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database emp;


Query OK, 1 row affected (0.01 sec)

mysql> use emp;


Database changed
mysql> create table employee(person_name varchar(20) primary key,street
varchar(20),city varchar(20));
Query OK, 0 rows affected (0.08 sec)

mysql> create table bank(bank_name varchar(20) primary key,city varchar(20));


Query OK, 0 rows affected (0.13 sec)

mysql> create table works(person_name varchar(20),bank_name varchar(20),salary


int,foreign key(person_name) references employee(person_name),foreign
key(bank_name) references bank(bank_name));
Query OK, 0 rows affected (0.11 sec)

mysql> create table manages(person_name varchar(20),manager_name


varchar(20),foreign key(person_name) references employee(person_name));
Query OK, 0 rows affected (0.05 sec)

mysql> insert into employee values('abhi','21','kanpur');


Query OK, 1 row affected (0.02 sec)

mysql> insert into employee values('ayushi','4','delhi');


Query OK, 1 row affected (0.03 sec)

mysql> insert into employee values('deepu','7','jaipur');


Query OK, 1 row affected (0.01 sec)

mysql> insert into employee values('mamta','67','lucknow');


Query OK, 1 row affected (0.01 sec)
mysql> insert into employee values('lovely','9','kolkata');
Query OK, 1 row affected (0.02 sec)

mysql> insert into bank values('Axis','kolkata');


Query OK, 1 row affected (0.05 sec)

mysql> insert into bank values('Kotak','mumbai');


Query OK, 1 row affected (0.02 sec)

mysql> insert into bank values('sbi','delhi');


Query OK, 1 row affected (0.02 sec)

mysql> insert into bank values('central','chennai');


Query OK, 1 row affected (0.03 sec)

mysql> insert into bank values('canara','delhi');


Query OK, 1 row affected (0.03 sec)

mysql> insert into works values('lovely','sbi',340000);


Query OK, 1 row affected (0.03 sec)

mysql> insert into works values('abhi','canara',670000);


Query OK, 1 row affected (0.05 sec)

mysql> insert into works values('mamta','Axis',670000);


Query OK, 1 row affected (0.02 sec)

mysql> insert into works values('ayushi','Kotak',9999000);


Query OK, 1 row affected (0.06 sec)

mysql> insert into works values('deepu','Kotak',999000);


Query OK, 1 row affected (0.02 sec)

mysql> insert into manages values('abhi','ak singh');


Query OK, 1 row affected (0.02 sec)

mysql> insert into manages values('ayushi','sk singh');


Query OK, 1 row affected (0.03 sec)

mysql> insert into manages values('deepu','hl duta');


Query OK, 1 row affected (0.03 sec)

mysql> insert into manages values('mamta','hc verma');


Query OK, 1 row affected (0.02 sec)

mysql> insert into manages values('lovely','singhal');


Query OK, 1 row affected (0.03 sec)

mysql> select * from employee;


+-------------+--------+---------+
| person_name | street | city |
+-------------+--------+---------+
| mamta | 67 | lucknow |
| deepu | 7 | jaipur |
| ayushi | 4 | delhi |
| lovely | 9 | kolkata |
| abhi | 21 | kanpur |
+-------------+--------+---------+
5 rows in set (0.00 sec)

mysql> select * from bank;


+-----------+---------+
| bank_name | city |
+-----------+---------+
| Axis | kolkata |
| canara | delhi |
| central | chennai |
| Kotak | mumbai |
| sbi | delhi |
+-----------+---------+
5 rows in set (0.00 sec)

mysql> select * from works;


+-------------+-----------+---------+
| person_name | bank_name | salary |
+-------------+-----------+---------+
| lovely | sbi | 340000 |
| abhi | canara | 670000 |
| mamta | Axis | 670000 |
| ayushi | Kotak | 9999000 |
| deepu | Kotak | 999000 |
+-------------+-----------+---------+
5 rows in set (0.00 sec)

mysql> select * from manages;


+-------------+--------------+
| person_name | manager_name |
+-------------+--------------+
| abhi | ak singh |
| ayushi | sk singh |
| deepu | hl duta |
| mamta | hc verma |
| lovely | singhal |
+-------------+--------------+
5 rows in set (0.00 sec)

mysql> alter table employee add email varchar(20);


Query OK, 5 rows affected (0.17 sec)
Records: 5 Duplicates: 0 Warnings: 0

mysql> select manager_name from works inner join manages on


manages.person_name=works.person_name where works.bank_name='Axis' or
works.bank_name='Kotak';
+--------------+
| manager_name |
+--------------+
| sk singh |
| hl duta |
| hc verma |
+--------------+
3 rows in set (0.00 sec)

mysql> select employee.person_name,street,employee.city,salary from works inner


join employee on employee.person_name=works.person_name where
works.bank_name='Axis' and salary>10000;
+-------------+--------+---------+--------+
| person_name | street | city | salary |
+-------------+--------+---------+--------+
| mamta | 67 | lucknow | 670000 |
+-------------+--------+---------+--------+
1 row in set (0.00 sec)

mysql> select employee.person_name from works inner join employee on


employee.person_name=works.person_name
-> inner join bank on bank.bank_name=works.bank_name
-> where employee.city=bank.city;
Empty set (0.00 sec)

mysql> select works.bank_name,max(salary),min(salary),avg(salary) from works group


by works.bank_name;
+-----------+-------------+-------------+--------------+
| bank_name | max(salary) | min(salary) | avg(salary) |
+-----------+-------------+-------------+--------------+
| Axis | 670000 | 670000 | 670000.0000 |
| canara | 670000 | 670000 | 670000.0000 |
| Kotak | 9999000 | 999000 | 5499000.0000 |
| sbi | 340000 | 340000 | 340000.0000 |
+-----------+-------------+-------------+--------------+
4 rows in set (0.00 sec)

mysql> select works.bank_name,sum(salary),count(works.person_name) from works group


by works.bank_name;
+-----------+-------------+--------------------------+
| bank_name | sum(salary) | count(works.person_name) |
+-----------+-------------+--------------------------+
| Axis | 670000 | 1 |
| canara | 670000 | 1 |
| Kotak | 10998000 | 2 |
| sbi | 340000 | 1 |
+-----------+-------------+--------------------------+
4 rows in set (0.00 sec)

QUESTION 5
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.62 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database inventory;


Query OK, 1 row affected (0.00 sec)

mysql> use inventory;


Database changed
mysql> create table suppliers(sno int primary key,sname char(20),status int,scity
char(20));
Query OK, 0 rows affected (0.14 sec)

mysql> insert into suppliers values(1,'abc',20,'delhi');


Query OK, 1 row affected (0.08 sec)

mysql> insert into suppliers values(1,'say',30,'paris');


ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY'
mysql> insert into suppliers values(2,'say',30,'paris');
Query OK, 1 row affected (0.06 sec)

mysql> insert into suppliers values(3,'say',50,'london');


Query OK, 1 row affected (0.05 sec)

mysql> insert into suppliers values(4,'xyz',10,'uk');


Query OK, 1 row affected (0.06 sec)

mysql> create table parts(pno int primary key,pname int,colour char(20),weight


int,city char(30));
Query OK, 0 rows affected (0.09 sec)

mysql> drop table parts;


Query OK, 0 rows affected (0.08 sec)

mysql> desc parts;


ERROR 1146 (42S02): Table 'inventory.parts' doesn't exist
mysql> create table parts(pno char(3) primary key,pname char(40);colour
char(10);weight int,city char(30));
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'colour
char(10)' at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'weight
int,city char(30))' at line 1
mysql> create table parts(pno char(3) primary key,pname char(40),colour
char(10),weight int,city char(30));
Query OK, 0 rows affected (0.11 sec)

mysql> insert into parts values('p1','ab','blue',78,'paris');


Query OK, 1 row affected (0.06 sec)

mysql> insert into parts values('p2','cd','red',20,'paris');


Query OK, 1 row affected (0.06 sec)

mysql> insert into parts values('p3','ef','red',12,'paris');


Query OK, 1 row affected (0.05 sec)

mysql> insert into parts values('p4','gh','red',12,'london');


Query OK, 1 row affected (0.06 sec)

mysql> insert into parts values('p5','ij','white',12,'delhi');


Query OK, 1 row affected (0.05 sec)

mysql> create table project(jno char(3) primary key,jname char(20),jcity(20));


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '(20))'
at line 1
mysql> create table project(jno char(3) primary key,jname char(20),jcity char(20));
Query OK, 0 rows affected (0.09 sec)
mysql> insert into project values('j1','kl','paris');
Query OK, 1 row affected (0.05 sec)

mysql> insert into project values('j2','mn','paris');


Query OK, 1 row affected (0.06 sec)

mysql> insert into project values('j3','pq','london');


Query OK, 1 row affected (0.06 sec)

mysql> insert into project values('j4','rs','delhi');


Query OK, 1 row affected (0.06 sec)

mysql> select sno from suppliers where status>20;


+-----+
| sno |
+-----+
| 2 |
| 3 |
+-----+
2 rows in set (0.00 sec)

mysql> create table shipment(foreign key(sno) references suppliers(sno),foreign


key(pno) references parts(pno),foreign key(jno) references project(jno),quantity
int);
ERROR 1072 (42000): Key column 'sno' doesn't exist in table
mysql> create table shipment(sno int,pno char(3),jno char(3),foreign key(sno)
references suppliers(sno),foreign key(pno) references parts(pno),foreign key(jno)
references project(jno),quantity int);
Query OK, 0 rows affected (0.19 sec)

mysql> select * from suppliers,shipment where sno=pno orderby sno;


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'orderby
sno' at line 1
mysql> select * from suppliers,shipment where supplier.sno=shipment.pno orderby
sno;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'orderby
sno' at line 1
mysql> select * from suppliers,shipment where supplier.sno=shipment.pno orderby
suppliers.sno;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'orderby
suppliers.sno' at line 1
mysql> select distinct suppliers.sname from suppliers where exists(select * from
shipmentwhere shipment.sname=suppliers.sname and shipment.pno='p2');
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'.sname=suppliers.sname and shipment.pno='p2')' at line 1
mysql> insert into shipment values(1,'p1','j1',100);
Query OK, 1 row affected (0.06 sec)

mysql> insert into shipment values(2,'p1','j1',200);


Query OK, 1 row affected (0.06 sec)

mysql> insert into shipment values(2,'p2','j1',200);


Query OK, 1 row affected (0.05 sec)

mysql> insert into shipment values(3,'p3','j1',400);


Query OK, 1 row affected (0.06 sec)

mysql> insert into shipment values(3,'p2','j2',400);


Query OK, 1 row affected (0.06 sec)

mysql> select distinct suppliers.sname from suppliers where exists(select * from


shipmentwhere shipment.sname=suppliers.sname and shipment.pno='p2');
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'.sname=suppliers.sname and shipment.pno='p2')' at line 1
mysql> select distinct suppliers.sname from suppliers where exists(select * from
shipmentwhere shipment.sno=suppliers.sno and shipment.pno='p2');
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'.sno=suppliers.sno and shipment.pno='p2')' at line 1
mysql> select distinct suppliers.sname from suppliers where exists(select * from
shipmentwhere shipment.sno=suppliers.sno and shipment.pno='p2');
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'.sno=suppliers.sno and shipment.pno='p2')' at line 1
mysql> select distinct suppliers.sname from suppliers where exists(select * from
shipment,suppliers where shipment.sno=suppliers.sno and shipment.pno='p2');
+-------+
| sname |
+-------+
| abc |
| say |
| xyz |
+-------+
3 rows in set (0.06 sec)

mysql> select distinct suppliers.sname from suppliers where not exists(select *


from shipment,suppliers where shipment.sno=suppliers.sno and shipment.pno='p2');
Empty set (0.01 sec)

mysql> select * from shipment where weight>=300 and weight<=750;


ERROR 1054 (42S22): Unknown column 'weight' in 'where clause'
mysql> select * from shipment where quantity>=300 and quantity<=750;
+------+------+------+----------+
| sno | pno | jno | quantity |
+------+------+------+----------+
| 3 | p3 | j1 | 400 |
| 3 | p2 | j2 | 400 |
+------+------+------+----------+
2 rows in set (0.00 sec)

mysql> select parts.pno from parts where weight>16 union select shipment.pno from
shipment where shipment.sno='2';
+------+
| pno |
+------+
| p1 |
| p2 |
+------+
2 rows in set (0.05 sec)

Potrebbero piacerti anche