SQL pratical-05

an anonymous user · September 23, 2022
welcome to the MYSQL monitor.Commands end with ; or \g.
Your MYSQL connection id is 11
server version:8.0.26 MYSQL community server - GPL

copyright (c) 2000,2021,oracal and /or its affiliates.

oracal is the registered trademark of oracal corporation and/or its affiliates.
other names may be trademark of their respective owners.

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

mysql>show database;
+-------------------+
|   Database        |         
+-------------------+
| amitdb            |
| costumers         |
| custumer          |
| information_schema|
| mysql             |
| performance_schema|
| students          |
| sys               |
+-------------------+
8 row in set (0.00 sec)
mysql> drop database students;
Query OK, 0 row affected (0.06 sec)

mysql> create databade student;
Query OK,1 row affected (0.05 sec)

mysql> use students;
Database changed
mysl> create table students
   -> (
   -> rollno int,
   -> name varchar (20),
   -> gender varchar(30),
   -> marks varchar (20)
   -> );
   Query OK, 0 row affected (0.12 sec)
   -> marks varchar (20)
   -> );
Query OK, 0 row affected (0.12 sec)
   
mysql> desc students;
+-------+------------+--------+------+---------+-------+ 
| field | Type       | Null   | Key  | Default | Extra |
+-------+------------+--------+------+---------+-------+
| rollno|  int       | YES    |      | NULL    |       | 
| name  | varchar(20)| YES    |      | NULL    |       |
| gender| varchar(30)| YES    |      | NULL    |       |
| marks | varchar(20)| YES    |      | NULL    |       |
+-------+------------+--------+------+---------+-------+
4 rows in set (0.05 sec)

mysql> insert into students vlue(1,'Kartika','Female','97');
Query OK, 1 row affected (0.06 sec)

mysql> insert into students value(2,'Neha','Female','93');
Query OK, 1 row affected (0.05 sec)

mysql> insert into students value(3,'Raj','Male','96');
Query OK, 1 row affected (0.05 sec)

mysql>insert into students value(4,'Om','Male', '91');
Query OK,1 row affected (0.05 sec)

mysql>select * from students;
+-------+----------+----------+-------+
| rollno| name     | gender   | marks |
+-------+----------+----------+-------+
|    1  | Kartika  | Female   | 97    |
|    2  | Neha     | Female   | 93    |
|    3  | Raj      | Female   | 96    |
|    4  | Om       | Female   | 91    |
+-------+----------+----------+-------+
4 row in set (0.00 sec)

mysql> select * from students where marks=97;
+-------+--------+--------+--------+
| rollno| name   | gender |marks   |
+-------+--------+--------+--------+
|    1  | Kartika| Female |  97    |
+-------+--------+--------+--------+
1 row in set (0.00 sec)

mysql> select * from students where marks<95;
+----------+----------+----------+----------+
| rollno   |  name    |  gender  | marks    |
+----------+----------+----------+----------+
|    2     | Neha     | Female   | 93       |
|    4     | Om       | Male     | 91       |
+----------+----------+----------+----------+
2 row in set (0.00 sec)

mysql> select * from students where marks>95;
+----------+----------+----------+----------+
|    rollno|  name    |  gender  | marks    | 
+----------+----------+----------+----------+
|     1    | Kartika  | Female   |  97      |
|     3    | Raj      | Male     |  96      |
+----------+----------+----------+----------+
2 row in set (0.00 sec)

mysql> select * from students where marks between 93 and 99;
+----------+----------+----------+----------+
|  rollno  | name     |  gender  | marks    |
+----------+----------+----------+----------+
|    1     | Kartika  |  Female  | 97       |
|    2     | Neha     |  Female  | 93       |
|    3     | Raj      |  Male    | 96       |
+----------+----------+----------+----------+
3 row in set (0.00 sec)

mysql> select * from students where in ('97','93');
+----------+----------+----------+----------+
| rollno   | name     |  gender  | marks    |
+----------+----------+----------+----------+
|   1      | Kartika  | Female   | 97       |
|   2      | Neha     | Female   | 93       |
+----------+----------+----------+----------+
2 row in set (0.04 sec)

mysql> select * from students where marks<=93;
+----------+----------+----------+----------+
|  rollno  | name     |  gender  | marks    |
+----------+----------+----------+----------+
|    2     | Neha     | Female   |  93      |
|    4     | Om       | Male     |  91      |
+----------+----------+----------+----------+
2 rows in set (0.00 sec)
Output
(Run the program to view its output)

Comments

Please sign up or log in to contribute to the discussion.