top of page

HOW TO JOIN TABLES IN MYSQL

TODAY I WILL EXPLAIN YOU HOW TO JOIN TOW TABLES IN MY SQL

REQUIREMENT

MYSQL SOFTWARE

DOWNLOAD LINK HERE

https://dev.mysql.com/downloads/installer/

LETS START

1 CREATE DATABASE

A database is a collection of information that is organized so that it can easily be accessed, managed, and updated.

QUERY FOR CREATE DATABASE

CREATE DATABASE(DATABASE NAME);

2 USE DATABASE

QUERY FOR USE DATABASE

USE (DATABASE NAME );

FOR EXP:- USE STUDENT;

(STUDENT IS A DATABASE NAME)

3 CREATE TABLE

QUERY FOR CREATE TABLE IN DATABASE

CREATE TABLE (TABLE NAME)(COL NAME (DATATYPE)(SIZE);

4 DEFINE PRIMARY KEY IN THE TABLE

PRIMARY KEY:-A primary key is a special relational database table column (or combination of columns) designated to uniquely identify all table records. A primary key's main features are: It must contain a unique value for each row of data. It cannot contain null values.

THEN AGAIN CREATE 2ND TABLE

WITH THE HELP OF SAME QUERY

5 AGAIN DEFINE PRIMARY KEY IN THE 2ND TABLE

6 DEFINE FOREIGN KEY IN THE 2ND TABLE

FOREIGN KEY:-A foreign key is a column (or columns) that references a column (most often the primary key) of another table. The purpose of the foreign key is to ensure referential integrity of the data. In other words, only values that are supposed to appear in the database are permitted.

THEN FINALLY JOIN TWO TABLES

TYPES OF JOIN

1) NON-EQUI JOIN:- An nonequi (or theta) join is an inner join statement that uses an unequal operation (i.e: <>, >, <, !=, BETWEEN, etc.) to match rows from different tables. The converse of an nonequi join is a equi join operation

2) EQUI JOIN:-An equijoin is a join with a join condition containing an equality operator. An equijoin returns only the rows that have equivalent values for the specified columns. An inner join is a join of two or more tables that returns only those rows (compared using a comparison operator) that satisfy the join condition.

FORMULA TO CALCULATE TOTAL RECORD AFTER NON EQUI JOIN

TOTAL COLUMN=COLUMN OF 1ST TABLE+COLUMN OF 2ND TABLE

TOTAL ROWS= TOTAL RECORD OF 1ST TABLE x TOTAL RECORD OF 2ND TABLE

RECORD=ROWS OF TABLE(EXCLUDE HEADER)

QUERY FOR NON EQUI JOIN

SELECT * FROM (TABLE1,TABLE2);

FOR EXP

SELECT * FROM EMP,DEPT;

QUERY FOR EQUI JOIN

SELECT * FROM (TABLE1,TABLE2) WHERE (TABLE NAME).(PRIMARY KEY)=(TABLE NAME).(FOREIGN KEY OF 2ND TABLE);

FOR EXP

SELECT * FROM EMP,DEPT WHERE EMP.EMP1=DEPT.EMP1;

FINALLY TOW TABLES JOIN EACH OTHER

IF ANY QUESTION REGARDING THIS PLEASE ASK IN THE COMMENTS

AND GIVE YOUR REVIEW ON THIS VIDEO

......................................CONGRATULATION..........................................

VISIT ON MY SITE AND SUBSCRIBE FOR LATEST VIDEOS AND NEWS UPDATES

https://betechy1998.wixsite.com/betechyyr

BE TECHY YR APP LINK

https://drive.google.com/open?id=0BzohIyvEOyjGRGVWMURDLWlfcGs

YOUTUBE CHANNEL

Please subscribe

https://www.youtube.com/channel/UCqXmmEADA21hpXXZAfyAVOA?sub_confirmation=1

SEE MORE VIDEOS:-

https://www.youtube.com/watch?v=_QqeqXSisxQ&list=PLqNm429el5fLmg55uYTtssJsBUqwzGgxc

PLAYLIST:-

https://www.youtube.com/playlist?list=PLqNm429el5fLmg55uYTtssJsBUqwzGgxc

SEE MY BLOG LINK HERE

http://betechyyr.blogspot.com/

FOLLOW US ON GOOGLE +

https://plus.google.com/u/0/

FOLLOW US ON TWITTER

https://twitter.com/sachin21742467

FOLLOW US ON FACEBOOK PAGE

https://www.facebook.com/betechyyr/

FOLLOW US ON INSTAGRAM

https://www.instagram.com/sachinsangwan/?hl=en

THANKS FOR

WATCHING MY VIDEOS

LIKE SHARE AND COMMENT

AND SUBSCRIBE MY CHANNEL

Thanku all of You

BE HAPPY AND STAY BLESSED

...................................ENJOY OUR LIFE..............................................

bottom of page