Joins in MySQL

Joins in MySQL

JOINS are used to retrieve data from multiple tables. It is performed whenever you need to fetch records from one (Self Join), two or more tables based on the common column between the tables and tables are mutually related using primary and foreign keys.

Types of Join

  • MySQL INNER JOIN (or sometimes called simple join)
  • MySQL LEFT OUTER JOIN (or sometimes called LEFT JOIN)
  • MySQL RIGHT OUTER JOIN (or sometimes called RIGHT JOIN)
  • MySQL CROSS JOIN
  • MySQL SELF JOIN

Practical Task

Create Database

create database practice

Create Table 1 with Primary Key

create table register (rollno int NOT NULL AUTO_INCREMENT,name varchar(250),email varchar(250),phone varchar(250), PRIMARY KEY (rollno),UNIQUE KEY(email))

Create Table 2 with Primary Key

create table fees(id int NOT NULL AUTO_INCREMENT,rollno int NOT NULL,fees int,status varchar(250), PRIMARY KEY (id),FOREIGN KEY(rollno) REFERENCES register (rollno) )

Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

*

*