0% found this document useful (0 votes)
7 views

#SPORTS TABLE SQL

The document outlines the creation and management of a sports database in MySQL, including the creation of a 'sports' table with various fields. It details the insertion of student records and several SQL queries to retrieve specific information, such as students with certain grades and games. The results of these queries demonstrate the database's functionality and the data it holds.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

#SPORTS TABLE SQL

The document outlines the creation and management of a sports database in MySQL, including the creation of a 'sports' table with various fields. It details the insertion of student records and several SQL queries to retrieve specific information, such as students with certain grades and games. The results of these queries demonstrate the database's functionality and the data it holds.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#SPORTS TABLE SQL

mysql> create database s1;


Query OK, 1 row affected (0.01 sec)

mysql> use s1;


Database changed
mysql> create table sports
-> (StudentNo integer(3),Class integer(3),Name Varchar(20) not null, Game
varchar(10), Grade1 char(1), SUPW varchar(20), Grade2 char(1));
Query OK, 0 rows affected (0.03 sec)

mysql> desc sports;


+-----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| StudentNo | int(3) | YES | | NULL | |
| Class | int(3) | YES | | NULL | |
| Name | varchar(20) | NO | | NULL | |
| Game | varchar(10) | YES | | NULL | |
| Grade1 | char(1) | YES | | NULL | |
| SUPW | varchar(20) | YES | | NULL | |
| Grade2 | char(1) | YES | | NULL | |
+-----------+-------------+------+-----+---------+-------+
7 rows in set (0.02 sec)
--------------------------------------------------------------------------------
mysql> insert into sports
-> values(10, 7, 'Sameer', 'Cricket', 'B','Photography','A');
Query OK, 1 row affected (0.01 sec)

mysql> insert into sports


-> values(11, 8, 'Sujeet', 'Tennis', 'A','Gardening','C');
Query OK, 1 row affected (0.01 sec)

mysql> insert into sports


-> values(12, 7, 'Kamal', 'Swimming', 'B','Photography','B');
Query OK, 1 row affected (0.00 sec)

mysql> insert into sports


-> values(13, 7, 'Veena', 'Tennis', 'C','Cooking','A');
Query OK, 1 row affected (0.00 sec)

mysql> insert into sports


-> values(14, 9, 'Archana', 'Basketball', 'A','Literature','A');
Query OK, 1 row affected (0.01 sec)
-------------------------------------------------------------------------------
mysql> select* from sports;
+-----------+-------+---------+------------+--------+-------------+--------+
| StudentNo | Class | Name | Game | Grade1 | SUPW | Grade2 |
+-----------+-------+---------+------------+--------+-------------+--------+
| 10 | 7 | Sameer | Cricket | B | Photography | A |
| 11 | 8 | Sujeet | Tennis | A | Gardening | C |
| 12 | 7 | Kamal | Swimming | B | Photography | B |
| 13 | 7 | Veena | Tennis | C | Cooking | A |
| 14 | 9 | Archana | Basketball | A | Literature | A |
+-----------+-------+---------+------------+--------+-------------+--------+
5 rows in set (0.01 sec)
------------------------------------------------------------------------------
#question1
mysql> select Name from sports where Grade1='C' or Grade2='C';
+--------+
| Name |
+--------+
| Sujeet |
| Veena |
+--------+
2 rows in set (0.00 sec)
-------------------------------------------------------------------------------
#question2
mysql> select Game from sports;
+------------+
| Game |
+------------+
| Cricket |
| Tennis |
| Swimming |
| Tennis |
| Basketball |
+------------+
5 rows in set (0.00 sec)
-------------------------------------------------------------------------------
#question3
mysql> select Name, SUPW from sports where Name like 'a%';
+---------+------------+
| Name | SUPW |
+---------+------------+
| Archana | Literature |
+---------+------------+
1 row in set (0.01 sec)
-------------------------------------------------------------------------------
#question4
mysql> select Name from sports where Game='Cricket' and Grade1='A';
Empty set (0.00 sec)
--------------------------------------------------------------------------------

You might also like