0% found this document useful (0 votes)
16 views1 page

SQL 1ans

The document contains SQL queries and results from a database with three tables: class, student, and class_student. It shows the details of classes, students, and their enrollments, including class names and associated course IDs. The final query retrieves student names along with their enrolled class names and course IDs.

Uploaded by

Nikita DAGA
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)
16 views1 page

SQL 1ans

The document contains SQL queries and results from a database with three tables: class, student, and class_student. It shows the details of classes, students, and their enrollments, including class names and associated course IDs. The final query retrieves student names along with their enrolled class names and course IDs.

Uploaded by

Nikita DAGA
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/ 1

mysql> select * from class;

+----------+-----------+-------------+------------+------------+------------+
| class_id | course_id | class_name | instructor | start_date | end_date |
+----------+-----------+-------------+------------+------------+------------+
| 2 | 201 | bca | NULL | NULL | NULL |
| 11 | 101 | mca | insabc | 2012-04-24 | 2025-08-24 |
| 21 | 201 | second_year | insxyz | 2012-11-24 | 2025-08-25 |
+----------+-----------+-------------+------------+------------+------------+
3 rows in set (0.00 sec)

mysql> select * from student;


+------------+------------+-----------+------------------+------------
+-----------------+
| student_id | first_name | last_name | email | phone |
enrollment_date |
+------------+------------+-----------+------------------+------------
+-----------------+
| 1 | Nikita | Nawandar | [email protected] | 1234567890 | 2012-03-25
|
| 2 | pooja | Nawandar | [email protected] | 1234560 | 2012-05-25
|
| 3 | madhur | Nawandar | [email protected] | 1234444560 | 2014-05-25
|
+------------+------------+-----------+------------------+------------
+-----------------+
3 rows in set (0.00 sec)

mysql> select * from class_student;


+------------------+----------+------------+
| class_student_id | class_id | student_id |
+------------------+----------+------------+
| 1 | 11 | 1 |
| 2 | 21 | 2 |
| 3 | 2 | 2 |
+------------------+----------+------------+
3 rows in set (0.00 sec)

mysql> SELECT s.first_name, s.last_name, s.email, c.course_name FROM student s JOIN


class_student cs ON s.student_id = cs.student_id JOIN course c ON cs.class_id =
c.course_id;
Empty set (0.04 sec)

mysql> SELECT s.student_id, s.first_name, s.last_name, c.class_name, c.course_id


FROM student s JOIN class_student cs ON s.student_id = cs.student_id JOIN class c
ON cs.class_id = c.class_id;
+------------+------------+-----------+-------------+-----------+
| student_id | first_name | last_name | class_name | course_id |
+------------+------------+-----------+-------------+-----------+
| 1 | Nikita | Nawandar | mca | 101 |
| 2 | pooja | Nawandar | second_year | 201 |
| 2 | pooja | Nawandar | bca | 201 |
+------------+------------+-----------+-------------+-----------+
3 rows in set (0.00 sec)

You might also like