SQL Job 28TH Feb
SQL Job 28TH Feb
SQL Job 28TH Feb
mysql> create table DOCTOR(DID CHAR(3) PRIMARY KEY,DNAME VARCHAR(30) NOT NULL,DEPT
CHAR(5),CHARGES INTEGER,VISITDAYS CHAR(4) NOT NULL);
ERROR 1046 (3D000): No database selected
mysql> USE D1;
Database changed
mysql> create table DOCTOR(DID CHAR(3) PRIMARY KEY,DNAME VARCHAR(30) NOT NULL,DEPT
CHAR(5),CHARGES INTEGER,VISITDAYS CHAR(4) NOT NULL);
Query OK, 0 rows affected (0.09 sec)
mysql> SELECT * FROM DOCTOR WHERE CHARGES BETWEEN 2000 AND 3500;
Empty set (0.00 sec)
mysql> SELECT * FROM DOCTOR WHERE CHARGES BETWEEN 2000 AND 4000;
+-----+-------------+-------+---------+-----------+
| DID | DNAME | DEPT | CHARGES | VISITDAYS |
+-----+-------------+-------+---------+-----------+
| D05 | M.FERNANDEZ | ORTHO | 4000 | THU |
+-----+-------------+-------+---------+-----------+
1 row in set (0.00 sec)
-----------------------------------------------------------------------------------------------------------------------------------
mysql> SELECT * FROM DOCTOR;
+-----+-------------+-------+--------+-----------+------------+
| DID | DNAME | DEPT | CHARGE | VISITDAYS | DOJ |
+-----+-------------+-------+--------+-----------+------------+
| D01 | R.SHARMA | ENT | 1000 | MON | 2007-09-11 |
| D02 | D.BASAK | ENT | 1500 | WED | 2007-04-21 |
| D03 | M.AGARWAL | PAED | 6000 | SAT | 2009-12-25 |
| D04 | E.JOSEPH | ORTHO | 1260 | SUN | 2011-10-08 |
| D05 | M.FERNANDEZ | ORTHO | 4200 | THU | 2011-06-18 |
+-----+-------------+-------+--------+-----------+------------+
5 rows in set (0.00 sec)
mysql> SELECT
-> * FROM DOCTOR WHERE DNAME LIKE '%SHARMA%';
+-----+----------+------+--------+-----------+------------+
| DID | DNAME | DEPT | CHARGE | VISITDAYS | DOJ |
+-----+----------+------+--------+-----------+------------+
| D01 | R.SHARMA | ENT | 1000 | MON | 2007-09-11 |
| DO6 | A.SHARMA | PAED | 3000 | MON | 2005-09-13 |
| DO7 | K.SHARMA | ENT | 1000 | TUE | 2006-05-04 |
+-----+----------+------+--------+-----------+------------+
3 rows in set (0.00 sec)
mysql> SELECT * FROM DOCTOR WHERE YEAR(DOJ) BETWEEN 2006 AND 2008;
+-----+----------+------+--------+-----------+------------+
| DID | DNAME | DEPT | CHARGE | VISITDAYS | DOJ |
+-----+----------+------+--------+-----------+------------+
| D01 | R.SHARMA | ENT | 1000 | MON | 2007-09-11 |
| D02 | D.BASAK | ENT | 1500 | WED | 2007-04-21 |
| DO7 | K.SHARMA | ENT | 1000 | TUE | 2006-05-04 |
| DO8 | M.ROY | ENT | 2000 | MON | 2006-08-14 |
+-----+----------+------+--------+-----------+------------+
4 rows in set (0.00 sec)
mysql> SELECT * FROM DOCTOR WHERE YEAR(DOJ) BETWEEN 2006 AND 2008 ORDER BY VISITDAYS
DESC;
+-----+----------+------+--------+-----------+------------+
| DID | DNAME | DEPT | CHARGE | VISITDAYS | DOJ |
+-----+----------+------+--------+-----------+------------+
| D02 | D.BASAK | ENT | 1500 | WED | 2007-04-21 |
| DO7 | K.SHARMA | ENT | 1000 | TUE | 2006-05-04 |
| D01 | R.SHARMA | ENT | 1000 | MON | 2007-09-11 |
| DO8 | M.ROY | ENT | 2000 | MON | 2006-08-14 |
+-----+----------+------+--------+-----------+------------+
4 rows in set (0.00 sec)
--------------------------------------------------------------------------------------------------------------------------------------
------------------
05/03/2024
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| d1 |
| employee |
| information_schema |
| mysql |
| performance_schema |
| student |
+--------------------+
6 rows in set (0.03 sec)