Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • SQL Tutorial -> Sql Joins

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 352
    Comment on it

    <-- Chapter 24: SQL Aliases

    Chapter 25

    SQL Joins


    SQL Joins clause are used to combine data rows from two or more than two tables according to common field values between them.


    Lets see an examples from the below tables "customers" :-


    customer_id name country
    1 abc India
    2 def Australia
    3 ghi USA
    4 jkl India
    5 mno Bangladesh

    Lets see an examples from the below tables "orders" :-


    date customer_id amount
    30-11-2015 2 3000
    30-11-2015 1 1500
    31-12-2015 1 2000
    31-12-2015 3 2000

    SQL JOIN syntax :-


    SELECT `customers`.`name` AS [Customer Name], `orders`.`date` AS `Date`
    FROM `orders`
    JOIN `customers`
    ON `orders`.`customer_id` = `customers`.`customer_id`; 
    

    Now run the above SQL query, we will see the output below :-


    Customer Name Date
    def 30-11-2015
    abc 30-11-2015
    abc 31-12-2015
    ghi 31-12-2015

    Now we can see here, we have displayed customer name and order date of customer on the basis of common customer_id between customers and orders tables.


    There are different SQL Joins :-


    • INNER JOIN

    • LEFT JOIN

    • RIGHT JOIN

    • FULL JOIN


    We will learn about all these JOINS in coming chapters.

    Chapter 26: SQL Inner Join -->

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: