USING JOIN



MySQL - Using Join


JOINS are used to combine rows from two or more tables, based on a related column between those tables. The following are the types of joins:

SYNTAX :

SELECT columns  
FROM table1   
JOIN_NAME table2  
ON table1.column = table2.column;  


  • INNER JOIN: This join returns those records which have matching values in both the tables.

  • FULL JOIN: This join returns all those records which either have a match in the left or the right table.

  • LEFT JOIN: This join returns records from the left table, and also those records which satisfy the condition from the right table.

  • RIGHT JOIN: This join returns records from the right table, and also those records which satisfy the condition from the left table.


    LEFT JOIN :

    LEFT join returns records from the left table, and also those records which satisfy the condition from the right table.

    EXAMPLE :

    SELECT a.StudentName,a.Studentclass,b.Studentmarks
    FROM Studentinfo as a
    LEFT JOIN Studentmarks as b ON a.StudentID
    

    StudentNameStudentclassStudentmarks
    Manjushasixth500
    Manjushasixth465
    Manjushasixth520
    Manjushasixth450
    Noothansixth500
    Noothansixth465
    Noothansixth520
    Noothansixth450
    Meherishsixth500
    Meherishsixth465
    Meherishsixth520
    Meherishsixth450
    Ajaashitenth500
    Ajaashitenth465
    Ajaashitenth520
    Ajaashitenth450
    Sahayanasixth500
    Sahayanasixth465
    Sahayanasixth520
    Sahayanasixth450
    Sweekruthasixth500
    Sweekruthasixth465
    Sweekruthasixth520
    Sweekruthasixth450

    RIGHT JOIN :


    RIGHT join returns records from the right table, and also those records which satisfy the condition from the left table.


    SYNTAX :


    SELECT a.StudentName,a.Studentclass,b.Studentmarks
    FROM Studentinfo as a
    RIGHT JOIN Studentmarks as b ON a.StudentID
    

    StudentNameStudentclassStudentmarks
    Manjushasixth500
    Noothansixth500
    Meherishsixth500
    Ajaashitenth500
    Sahayanasixth500
    Sweekruthasixth500
    manjusixth500
    Manjushasixth500
    Noothansixth500
    Meherishsixth500
    Ajaashitenth500
    Sahayanasixth500
    Sweekruthasixth500
    manjusixth500
    Manjushasixth465
    Noothansixth465
    Meherishsixth465
    Ajaashitenth465
    Sahayanasixth465
    Sweekruthasixth465
    manjusixth465
    Manjushasixth520
    Noothansixth520
    Meherishsixth520
    Ajaashitenth520
    Sahayanasixth520
    Sweekruthasixth520
    manjusixth520
    Manjushasixth450
    Noothansixth450
    Meherishsixth450
    Ajaashitenth450
    Sahayanasixth450
    Sweekruthasixth450
    manjusixth450

    INNER JOIN :


    This join returns those records which have matching values in both the tables.


    EXAMPLE :

    
    SELECT studentrecord.StudentID, Studentinfo.StudentName
    FROM studentrecord
    INNER JOIN studentinfo ON studentrecord.StudentId = studentinfo.StudentId;
    
    
    

    StudentIDStudentName
    1Manjusha
    2Noothan

    FULL JOIN :


    This join returns all those records which either have a match in the left or the right table.


    SYNTAX : 
    
    SELECT column_name(s)
    FROM table1
    FULL OUTER JOIN table2 ON table1.column_name = table2.column_name;
    


    MySQL TRIGGERS

    MySQL - Triggers

    posted on 2019-11-29 21:44:07 - mysql Tutorials


    Grant_ Revoke Privilege

    MySQL - Grant_ Revoke Privilege

    posted on 2019-11-26 23:15:04 - mysql Tutorials


    MySQL Vs SQL

    MySQL Vs SQL

    posted on 2019-11-25 05:02:26 - mysql Tutorials


    how to use range in golang

    how to use range in golang

    posted on 2022-05-03 08:28:11 - Go lang Tutorials


    find variable type in golang

    find variable type in golang

    posted on 2022-05-03 05:24:55 - Go lang Tutorials


    for loops in golang

    for loops in golang

    posted on 2022-05-03 04:27:40 - Go lang Tutorials