0% found this document useful (0 votes)
23 views9 pages

p5 2340123

The document contains a series of MySQL commands executed on a database named 'library'. It includes commands to show databases, tables, and details about the 'books' table, such as its structure and various queries to retrieve specific data based on conditions like available copies and author names. The results of these queries provide insights into the books available in the library, including their titles, authors, ISBNs, and available copies.

Uploaded by

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

p5 2340123

The document contains a series of MySQL commands executed on a database named 'library'. It includes commands to show databases, tables, and details about the 'books' table, such as its structure and various queries to retrieve specific data based on conditions like available copies and author names. The results of these queries provide insights into the books available in the library, including their titles, authors, ISBNs, and available copies.

Uploaded by

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

mysql> show databases;

+--------------------+
| Database |
+--------------------+
| information_schema |
| library |
| library1 |
| library2 |
| mylibrary |
| mysql |
| performance_schema |
| sys |
+--------------------+
8 rows in set (0.00 sec)

mysql> use library;


Database changed

mysql> show tables;


+-------------------+
| Tables_in_library |
+-------------------+
| accounts |
| authors |
| bank_accounts |
| bookcopies |
| books |
| categories |
| courses |
| customers |
| departments |
| employees |
| enrollments |
| invoices |
| lib1 |
| library1 |
| library2 |
| library3 |
| library4 |
| library5 |
| orders |
| products |
| projects |
| students |
| users |
| vehicles |
+-------------------+
24 rows in set (0.00 sec)

mysql> desc books;


+-----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+-------------+------+-----+---------+-------+
| bookid | int | NO | PRI | NULL | |
| title | varchar(50) | YES | | NULL | |
| author | varchar(20) | YES | | NULL | |
| isbn | varchar(30) | YES | | NULL | |
| availablecopies | int | YES | | NULL | |
+-----------------+-------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

mysql> select*from books;


+--------+--------+------------+-------+-----------------+
| bookid | title | author | isbn | availablecopies |
+--------+--------+------------+-------+-----------------+
| 121 | indian | dystopian | 54332 | 20 |
| 122 | indian | harper lee | 54333 | 10 |
| 123 | indian | soott | 54331 | 100 |
| 124 | NULL | indian | 5434 | 30 |
| 2345 | indian | efg | 34 | 54 |
+--------+--------+------------+-------+-----------------+
5 rows in set (0.00 sec)

mysql> select*from books where bookid=121;


+--------+--------+-----------+-------+-----------------+
| bookid | title | author | isbn | availablecopies |
+--------+--------+-----------+-------+-----------------+
| 121 | indian | dystopian | 54332 | 20 |
+--------+--------+-----------+-------+-----------------+
1 row in set (0.00 sec)

mysql> select*from books where availablecopies<100;


+--------+--------+------------+-------+-----------------+
| bookid | title | author | isbn | availablecopies |
+--------+--------+------------+-------+-----------------+
| 121 | indian | dystopian | 54332 | 20 |
| 122 | indian | harper lee | 54333 | 10 |
| 124 | NULL | indian | 5434 | 30 |
| 2345 | indian | efg | 34 | 54 |
+--------+--------+------------+-------+-----------------+
4 rows in set (0.00 sec)

mysql> select*from books where availablecopies>50;


+--------+--------+--------+-------+-----------------+
| bookid | title | author | isbn | availablecopies |
+--------+--------+--------+-------+-----------------+
| 123 | indian | soott | 54331 | 100 |
| 2345 | indian | efg | 34 | 54 |
+--------+--------+--------+-------+-----------------+
2 rows in set (0.00 sec)

mysql> select*from books where availablecopies>=5;


+--------+--------+------------+-------+-----------------+
| bookid | title | author | isbn | availablecopies |
+--------+--------+------------+-------+-----------------+
| 121 | indian | dystopian | 54332 | 20 |
| 122 | indian | harper lee | 54333 | 10 |
| 123 | indian | soott | 54331 | 100 |
| 124 | NULL | indian | 5434 | 30 |
| 2345 | indian | efg | 34 | 54 |
+--------+--------+------------+-------+-----------------+
5 rows in set (0.00 sec)
mysql> select*from books where availablecopies<=20;
+--------+--------+------------+-------+-----------------+
| bookid | title | author | isbn | availablecopies |
+--------+--------+------------+-------+-----------------+
| 121 | indian | dystopian | 54332 | 20 |
| 122 | indian | harper lee | 54333 | 10 |
+--------+--------+------------+-------+-----------------+
2 rows in set (0.00 sec)

mysql> select*from books where author<>'dystopian';


+--------+--------+------------+-------+-----------------+
| bookid | title | author | isbn | availablecopies |
+--------+--------+------------+-------+-----------------+
| 122 | indian | harper lee | 54333 | 10 |
| 123 | indian | soott | 54331 | 100 |
| 124 | NULL | indian | 5434 | 30 |
| 2345 | indian | efg | 34 | 54 |
+--------+--------+------------+-------+-----------------+
4 rows in set (0.00 sec)

mysql> select*from books where bookid is null;


Empty set (0.00 sec)

mysql> select*from books where author is null;


Empty set (0.00 sec)

mysql> select*from books where bookid is not null;


+--------+--------+------------+-------+-----------------+
| bookid | title | author | isbn | availablecopies |
+--------+--------+------------+-------+-----------------+
| 121 | indian | dystopian | 54332 | 20 |
| 122 | indian | harper lee | 54333 | 10 |
| 123 | indian | soott | 54331 | 100 |
| 124 | NULL | indian | 5434 | 30 |
| 2345 | indian | efg | 34 | 54 |
+--------+--------+------------+-------+-----------------+
5 rows in set (0.00 sec)
mysql> select max(availablecopies) from books;
+----------------------+
| max(availablecopies) |
+----------------------+
| 100 |
+----------------------+
1 row in set (0.00 sec)

mysql> select avg(availablecopies) from books;


+----------------------+
| avg(availablecopies) |
+----------------------+
| 42.8000 |
+----------------------+
1 row in set (0.00 sec)

mysql> select count(availablecopies) from books;


+------------------------+
| count(availablecopies) |
+------------------------+
| 5|
+------------------------+
1 row in set (0.00 sec)

mysql> SELECT * FROM books


-> WHERE bookid IN (121, 122);
+--------+--------+------------+-------+-----------------+
| bookid | title | author | isbn | availablecopies |
+--------+--------+------------+-------+-----------------+
| 121 | indian | dystopian | 54332 | 20 |
| 122 | indian | harper lee | 54333 | 10 |
+--------+--------+------------+-------+-----------------+
2 rows in set (0.00 sec)

mysql> SELECT * FROM books


-> WHERE author IN ('harper lee', 'soott');
+--------+--------+------------+-------+-----------------+
| bookid | title | author | isbn | availablecopies |
+--------+--------+------------+-------+-----------------+
| 122 | indian | harper lee | 54333 | 10 |
| 123 | indian | soott | 54331 | 100 |
+--------+--------+------------+-------+-----------------+
2 rows in set (0.00 sec)

mysql> SELECT * FROM books


-> WHERE availablecopies BETWEEN 10 AND 50;
+--------+--------+------------+-------+-----------------+
| bookid | title | author | isbn | availablecopies |
+--------+--------+------------+-------+-----------------+
| 121 | indian | dystopian | 54332 | 20 |
| 122 | indian | harper lee | 54333 | 10 |
| 124 | NULL | indian | 5434 | 30 |
+--------+--------+------------+-------+-----------------+
3 rows in set (0.00 sec)

mysql> SELECT * FROM books


-> WHERE title LIKE 'ind%';
+--------+--------+------------+-------+-----------------+
| bookid | title | author | isbn | availablecopies |
+--------+--------+------------+-------+-----------------+
| 121 | indian | dystopian | 54332 | 20 |
| 122 | indian | harper lee | 54333 | 10 |
| 123 | indian | soott | 54331 | 100 |
| 2345 | indian | efg | 34 | 54 |
+--------+--------+------------+-------+-----------------+
4 rows in set (0.00 sec)

mysql> SELECT * FROM books


-> WHERE isbn LIKE '5433_';
+--------+--------+------------+-------+-----------------+
| bookid | title | author | isbn | availablecopies |
+--------+--------+------------+-------+-----------------+
| 121 | indian | dystopian | 54332 | 20 |
| 122 | indian | harper lee | 54333 | 10 |
| 123 | indian | soott | 54331 | 100 |
+--------+--------+------------+-------+-----------------+
3 rows in set (0.00 sec)

mysql> SELECT title AS book_title, author AS book_author


-> FROM books;
+------------+-------------+
| book_title | book_author |
+------------+-------------+
| indian | dystopian |
| indian | harper lee |
| indian | soott |
| NULL | indian |
| indian | efg |
+------------+-------------+
5 rows in set (0.00 sec)

mysql> SELECT * FROM books


-> WHERE availablecopies BETWEEN 10 AND 50
-> AND author = 'indian';
+--------+-------+--------+------+-----------------+
| bookid | title | author | isbn | availablecopies |
+--------+-------+--------+------+-----------------+
| 124 | NULL | indian | 5434 | 30 |
+--------+-------+--------+------+-----------------+
1 row in set (0.00 sec)

mysql> SELECT * FROM books


-> WHERE availablecopies > 50
-> OR author = 'harper lee';
+--------+--------+------------+-------+-----------------+
| bookid | title | author | isbn | availablecopies |
+--------+--------+------------+-------+-----------------+
| 122 | indian | harper lee | 54333 | 10 |
| 123 | indian | soott | 54331 | 100 |
| 2345 | indian | efg | 34 | 54 |
+--------+--------+------------+-------+-----------------+
3 rows in set (0.00 sec)

mysql> SELECT * FROM books


-> WHERE NOT author = 'soott';
+--------+--------+------------+-------+-----------------+
| bookid | title | author | isbn | availablecopies |
+--------+--------+------------+-------+-----------------+
| 121 | indian | dystopian | 54332 | 20 |
| 122 | indian | harper lee | 54333 | 10 |
| 124 | NULL | indian | 5434 | 30 |
| 2345 | indian | efg | 34 | 54 |
+--------+--------+------------+-------+-----------------+
4 rows in set (0.00 sec)

mysql> SELECT * FROM books


-> WHERE (author = 'indian' AND availablecopies BETWEEN 20 AND 100)
-> OR isbn LIKE '5433%';
+--------+--------+------------+-------+-----------------+
| bookid | title | author | isbn | availablecopies |
+--------+--------+------------+-------+-----------------+
| 121 | indian | dystopian | 54332 | 20 |
| 122 | indian | harper lee | 54333 | 10 |
| 123 | indian | soott | 54331 | 100 |
| 124 | NULL | indian | 5434 | 30 |
+--------+--------+------------+-------+-----------------+
4 rows in set (0.00 sec)

mysql> SELECT * FROM books


-> WHERE NOT author = 'efg'
-> OR bookid < 2000;
+--------+--------+------------+-------+-----------------+
| bookid | title | author | isbn | availablecopies |
+--------+--------+------------+-------+-----------------+
| 121 | indian | dystopian | 54332 | 20 |
| 122 | indian | harper lee | 54333 | 10 |
| 123 | indian | soott | 54331 | 100 |
| 124 | NULL | indian | 5434 | 30 |
+--------+--------+------------+-------+-----------------+
4 rows in set (0.00 sec)

mysql> notee;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy