0% found this document useful (0 votes)
13 views3 pages

DBMS Lab Experiment 4

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

DBMS Lab Experiment 4

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

EXPERIMENT-04

AIM OF THE EXPERIMENT-Create a database and use JOIN operations

mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.33-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

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

mysql> create database priyanka;


Query OK, 1 row affected (0.00 sec)

mysql> use priyanka;


Database changed
mysql> create table student(name varchar(20),city varchar(20),age int);
Query OK, 0 rows affected (0.25 sec)

mysql> insert into student values('ram','puri',20),('ravi','bbsr',21),('hari','kolkata',22);


Query OK, 3 rows affected (0.03 sec)
Records: 3 Duplicates: 0 Warnings: 0

mysql> select * from student;


+------+---------+------+
| name | city | age |
+------+---------+------+
| ram | puri | 20 |
| ravi | bbsr | 21 |
| hari | kolkata | 22 |
+------+---------+------+
3 rows in set (0.00 sec)

mysql> create table raja(name varchar(20),city varchar(20),age int);


Query OK, 0 rows affected (0.23 sec)
mysql> insert into raja values('ram','puri',20),('ravi','bbsr',21),('raj','kdp',23),('mili','aul',20),
('rina','puri',21);
Query OK, 5 rows affected (0.05 sec)
Records: 5 Duplicates: 0 Warnings: 0

mysql> select * from raja;


+------+------+------+
| name | city | age |
+------+------+------+
| ram | puri | 20 |
| ravi | bbsr | 21 |
| raj | kdp | 23 |
| mili | aul | 20 |
| rina | puri | 21 |
+------+------+------+
5 rows in set (0.00 sec)

mysql> select
* from
student union
select * from
raja;
+------+---------+------+
| name | city | age |
+------+---------+------+
| ram | puri | 20 |
| ravi | bbsr | 21 |
| hari | kolkata | 22 |
| raj | kdp | 23 |
| mili | aul | 20 |
| rina | puri | 21 |
+------+---------+------+
6 rows in set (0.00 sec)
mysql> select * from student union all select * from raja;
+------+---------+------+
| name | city | age |
+------+---------+------+
| ram | puri | 20 |
| ravi | bbsr | 21 |
| hari | kolkata | 22 |
| ram | puri | 20 |
| ravi | bbsr | 21 |
| raj | kdp | 23 |
| mili | aul | 20 |
| rina | puri | 21 |
+------+---------+------+
8 rows in set (0.00 sec)

mysql> select distinct NAME,CITY,AGE from student INNER JOIN raja


USING(NAME,CITY,AGE);
+------+------+------+
| NAME | CITY | AGE |
+------+------+------+
| ram | puri | 20 |
| ravi | bbsr | 21 |
+------+------+------+
2 rows in set (0.01 sec)

You might also like