macbook-pro:notebooks raj$ mysql -u raj -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 23
Server version: 8.0.21 Homebrew

Copyright (c) 2000, 2015, 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> use raj
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+---------------+
| Tables_in_raj |
+---------------+
| appt          |
| BUILDING      |
| call1         |
| MEDIA         |
| mytable       |
| ROOM          |
| ROOMMEDIA     |
| temp2         |
+---------------+
8 rows in set (0.00 sec)

mysql> source db.sql
Query OK, 0 rows affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 0 rows affected (0.02 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 1 row affected (0.00 sec)

mysql> commit
    -> ;
Query OK, 0 rows affected (0.00 sec)

mysql> show tables;
+---------------+
| Tables_in_raj |
+---------------+
| appt          |
| BUILDING      |
| call1         |
| CUSTOMERS     |
| MEDIA         |
| mytable       |
| ORDERS        |
| ROOM          |
| ROOMMEDIA     |
| temp2         |
+---------------+
10 rows in set (0.00 sec)

mysql> select distinct id, name
    -> from CUSTOMERS, ORDERS
    -> where  CUSTOMERS.id = ORDERS.customer_id;
+----+----------+
| id | name     |
+----+----------+
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
+----+----------+
5 rows in set (0.00 sec)

mysql> select *
    -> from orders
    -> ;
+-----+---------------------+-------------+--------+
| oid | date                | customer_id | amount |
+-----+---------------------+-------------+--------+
| 100 | 2009-10-08 00:00:00 |           3 |   1500 |
| 101 | 2009-11-20 00:00:00 |           2 |   1560 |
| 102 | 2009-10-08 00:00:00 |           3 |   3000 |
| 103 | 2008-05-20 00:00:00 |           4 |   2060 |
| 104 | 2010-10-07 00:00:00 |           3 |    500 |
| 105 | 2010-10-10 00:00:00 |           6 |   6560 |
| 106 | 2011-10-18 00:00:00 |           3 |   3200 |
| 107 | 2011-05-22 00:00:00 |           5 |   2960 |
| 108 | 2011-05-12 00:00:00 |           5 |   2960 |
| 109 | 2011-06-22 00:00:00 |           5 |   2960 |
| 110 | 2012-10-08 00:00:00 |           4 |    500 |
| 111 | 2012-11-20 00:00:00 |           2 |    560 |
| 112 | 2012-10-08 00:00:00 |           3 |   1000 |
| 113 | 2012-05-20 00:00:00 |           4 |   4060 |
| 114 | 2012-10-07 00:00:00 |           4 |   3500 |
| 115 | 2012-10-10 00:00:00 |           3 |   7560 |
| 116 | 2012-10-18 00:00:00 |           3 |    200 |
| 117 | 2012-05-22 00:00:00 |           5 |    960 |
| 118 | 2012-05-12 00:00:00 |           5 |   1960 |
| 119 | 2012-06-22 00:00:00 |           5 |   4960 |
+-----+---------------------+-------------+--------+
20 rows in set (0.00 sec)

mysql> select id,name from customers,orders;
+----+----------+
| id | name     |
+----+----------+
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
+----+----------+
140 rows in set (0.00 sec)

mysql> select distinct id, name
    -> from CUSTOMERS, ORDERS;
+----+----------+
| id | name     |
+----+----------+
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
+----+----------+
7 rows in set (0.00 sec)

mysql> select id, name
    -> from CUSTOMERS, ORDERS;
+----+----------+
| id | name     |
+----+----------+
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
|  1 | Ramesh   |
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
|  7 | Muffy    |
+----+----------+
140 rows in set (0.00 sec)

mysql> select id, name from CUSTOMERS, ORDERS where id = customer_id;
+----+----------+
| id | name     |
+----+----------+
|  2 | Khilan   |
|  2 | Khilan   |
|  3 | kaushik  |
|  3 | kaushik  |
|  3 | kaushik  |
|  3 | kaushik  |
|  3 | kaushik  |
|  3 | kaushik  |
|  3 | kaushik  |
|  4 | Chaitali |
|  4 | Chaitali |
|  4 | Chaitali |
|  4 | Chaitali |
|  5 | Hardik   |
|  5 | Hardik   |
|  5 | Hardik   |
|  5 | Hardik   |
|  5 | Hardik   |
|  5 | Hardik   |
|  6 | Komal    |
+----+----------+
20 rows in set (0.00 sec)

mysql> select distinct id, name from CUSTOMERS, ORDERS where id = customer_id;
+----+----------+
| id | name     |
+----+----------+
|  2 | Khilan   |
|  3 | kaushik  |
|  4 | Chaitali |
|  5 | Hardik   |
|  6 | Komal    |
+----+----------+
5 rows in set (0.00 sec)

mysql> -- Retrieve ids and names of customers who have placed an order
mysql> -- with amount more than $5000
mysql> 
mysql> select id, name
    -> from CUSTOMERS, ORDERS
    -> where  id = customer_id and
    ->        amount > 5000;
+----+---------+
| id | name    |
+----+---------+
|  3 | kaushik |
|  6 | Komal   |
+----+---------+
2 rows in set (0.00 sec)

mysql> select id, name
    -> from CUSTOMERS, ORDERS
    -> where  id = customer_id and
    ->        address = 'Kota' and
    ->        amount > 5000;
+----+---------+
| id | name    |
+----+---------+
|  3 | kaushik |
+----+---------+
1 row in set (0.00 sec)

mysql> -- Retrieve ids and names of customers who have placed orders
mysql> -- in 2011
mysql> 
mysql> select distinct id, name
    -> from CUSTOMERS, ORDERS
    -> where  id = customer_id and
    ->        year(date) = 2011;
+----+---------+
| id | name    |
+----+---------+
|  3 | kaushik |
|  5 | Hardik  |
+----+---------+
2 rows in set (0.01 sec)

mysql> exit
Bye