The document contains SQL queries and results from interacting with databases containing tables of coaching staff and club members. The tables were created and populated with sample data. Queries were written to retrieve summary statistics like counts, sums, maximums, and averages from the data. Joins were used to combine information from the tables. Records were inserted, updated, and deleted from the tables.
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 ratings0% found this document useful (0 votes)
567 views
Computer Project MySql Table On Club
The document contains SQL queries and results from interacting with databases containing tables of coaching staff and club members. The tables were created and populated with sample data. Queries were written to retrieve summary statistics like counts, sums, maximums, and averages from the data. Joins were used to combine information from the tables. Records were inserted, updated, and deleted from the tables.
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/ 8
mysql> USE XIIB;
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> CREATE TABLE COACH(COACHID CHAR(3),CNAME CHAR(15),DOJ DATE,SALARY INT,GEN DER CHAR(1),SPORT CHAR(15)); Query OK, 0 rows affected (0.10 sec) mysql> INSERT INTO COACH VALUES(I01,'KARAN','2006-3-27',10500,'M','KARATE'); ERROR 1054 (42S22): Unknown column 'I01' in 'field list' mysql> INSERT INTO COACH VALUES('I01','KARAN','2006-3-27',10500,'M','KARATE'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO COACH VALUES('I02','JENNY','2008-1-1',15000,'F','BASKETBALL') ; Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO COACH VALUES('I03','PETER','2010-10-21',13800,'M','CRICKET'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO COACH VALUES('I04','ANKITHA','2010-10-31',19800,'F','KARATE') ; Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO COACH VALUES('I05','AMAL','2002-8-23',17200,'M','CRICKET'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO COACH VALUES('I06','SUBIN','2012-10-10',12000,'M','BASKETBAL L'); Query OK, 1 row affected (0.00 sec) mysql> CREATE TABLE CLUB(ID INT,NAME CHAR(15),AGE INT,FEES INT,COACHID CHAR(3)); Query OK, 0 rows affected (0.14 sec) mysql> INSERT INTO CLUB VALUES(1,'KIRAN',12,450,'I03'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO CLUB VALUES(2,'KARTHIK',16,650,'I01'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO CLUB VALUES(3,'TOM',15,550,'I02'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO CLUB VALUES(4,'SID',9,500,'I03'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO CLUB VALUES(5,'JERRY',13,400,'I01'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO CLUB VALUES(6,'BALU',17,750,'I05'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO CLUB VALUES(7,'JOAN',14,650,'I06'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO CLUB VALUES(8,'ABDUL',11,400,'I04'); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO CLUB VALUES(9,'MEERA',13,300,'I02'); Query OK, 1 row affected (0.00 sec) Display the list of students gamewise mysql> SELECT NAME,SPORT FROM CLUB,COACH WHERE CLUB.COACHID=COACH.COACHID ORDER BY SPORT; +---------+------------+ | NAME | SPORT | +---------+------------+ | MEERA | BASKETBALL | | TOM | BASKETBALL | | JOAN | BASKETBALL | | KIRAN | CRICKET | | SID | CRICKET | | BALU | CRICKET | | KARTHIK | KARATE | | JERRY | KARATE | | ABDUL | KARATE | +---------+------------+ 9 rows in set (0.00 sec) Count the nuber of students in each game type mysql> SELECT COUNT(SPORT),SPORT FROM CLUB,COACH WHERE CLUB.COACHID=COACH.COACHI D GROUP BY SPORT; +--------------+------------+ | COUNT(SPORT) | SPORT | +--------------+------------+ | 3 | BASKETBALL | | 3 | CRICKET | | 3 | KARATE | +--------------+------------+ 3 rows in set (0.00 sec) Find average salary of coaches mysql> SELECT AVG(SALARY) FROM COACH; +-------------+ | AVG(SALARY) | +-------------+ | 14716.6667 | +-------------+ 1 row in set (0.00 sec) Display student name along with coach name mysql> SELECT NAME,CNAME FROM CLUB,COACH WHERE CLUB.COACHID=COACH.COACHID; +---------+---------+ | NAME | CNAME | +---------+---------+ | KIRAN | PETER | | KARTHIK | KARAN | | TOM | JENNY | | SID | PETER | | JERRY | KARAN | | BALU | AMAL | | JOAN | SUBIN | | ABDUL | ANKITHA | | MEERA | JENNY | +---------+---------+ 9 rows in set (0.00 sec) Display the number of students under each coach mysql> SELECT CNAME,COUNT(NAME) FROM CLUB,COACH WHERE CLUB.COACHID=COACH.COACHID GROUP BY CNAME; +---------+-----------+ | CNAME | COUNT(NAME) | +---------+-----------+ | AMAL | 1 | | ANKITHA | 1 | | JENNY | 2 | | KARAN | 2 | | PETER | 2 | | SUBIN | 1 | +---------+-----------+ 6 rows in set (0.00 sec) List the students for cricket or basketball mysql> SELECT NAME,SPORT FROM CLUB,COACH WHERE CLUB.COACHID=COACH.COACHID AND SP ORT IN('CRICKET','BASKETBALL'); +-------+------------+ | NAME | SPORT | +-------+------------+ | KIRAN | CRICKET | | TOM | BASKETBALL | | SID | CRICKET | | BALU | CRICKET | | JOAN | BASKETBALL | | MEERA | BASKETBALL | +-------+------------+ 6 rows in set (0.00 sec) Find the total fees paid for each game mysql> SELECT SPORT,SUM(FEES) FROM COACH,CLUB WHERE COACH.COACHID=CLUB.COACHID G ROUP BY SPORT; +------------+-----------+ | SPORT | SUM(FEES) | +------------+-----------+ | BASKETBALL | 1500 | | CRICKET | 1700 | | KARATE | 1450 | +------------+-----------+ 3 rows in set (0.00 sec) List the names of students who pay fees abve 500 mysql> SELECT NAME FROM CLUB WHERE FEES>500; +---------+ | NAME | +---------+ | KARTHIK | | TOM | | BALU | | JOAN | +---------+ 4 rows in set (0.00 sec) List the names of students in the age group 12-15 mysql> SELECT NAME FROM CLUB WHERE AGE>=12 AND AGE<=15; +-------+ | NAME | +-------+ | KIRAN | | TOM | | JERRY | | JOAN | | MEERA | +-------+ 5 rows in set (0.00 sec) Display the name and fees paid by the students in karate mysql> SELECT NAME,FEES FROM CLUB,COACH WHERE CLUB.COACHID=COACH.COACHID AND SPO RT LIKE 'KARATE'; +---------+------+ | NAME | FEES | +---------+------+ | KARTHIK | 650 | | JERRY | 400 | | ABDUL | 400 | +---------+------+ 3 rows in set (0.00 sec) Increase the fees paid by the students who are under coaches I03 AND I05 mysql> UPDATE CLUB SET FEES=FEES+50 WHERE COACHID IN('I03','I05'); Query OK, 3 rows affected (0.00 sec) Rows matched: 3 Changed: 3 Warnings: 0 Display the maximum and minimum fees paid by students in cricket mysql> SELECT MAX(FEES),MIN(FEES) FROM CLUB,COACH WHERE CLUB.COACHID=COACH.COACH ID AND SPORT='CRICKET'; +-----------+-----------+ | MAX(FEES) | MIN(FEES) | +-----------+-----------+ | 800 | 500 | +-----------+-----------+ 1 row in set (0.00 sec) Remove the details of Subin from the table mysql> DELETE FROM COACH WHERE CNAME='SUBIN'; Query OK, 1 row affected (0.00 sec) Display the details of all coaches who joined after 01/01/2009 mysql> SELECT CNAME FROM COACH WHERE DOJ>'2009-1-1'; +---------+ | CNAME | +---------+ | PETER | | ANKITHA | +---------+ 2 rows in set (0.00 sec) Display the maximum and minimum salary of each sport mysql> SELECT SPORT,MAX(SALARY),MIN(SALARY) FROM COACH GROUP BY SPORT; +------------+-------------+-------------+ | SPORT | MAX(SALARY) | MIN(SALARY) | +------------+-------------+-------------+ | BASKETBALL | 15000 | 15000 | | CRICKET | 17200 | 13800 | | KARATE | 19800 | 10500 | +------------+-------------+-------------+ 3 rows in set (0.00 sec) Name the different games offered by the club mysql> SELECT DISTINCT SPORT FROM COACH; +----------------+ | DISTINCT SPORT | +----------------+ | BASKETBALL | | CRICKET | | KARATE | +----------------+ 3 rows in set (0.00 sec) Display the number if different games offered by the club mysql> SELECT COUNT(DISTINCT SPORT) FROM COACH; +-----------------------+ | COUNT(DISTINCT SPORT) | +-----------------------+ | 3 | +-----------------------+ 1 row in set (0.00 sec)