Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • SQL Join Statement

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 212
    Comment on it

    Basically this tag is used with select statement to find and retrieve the data from multiple tables . And this can be done with the help of join query .
    suppose i have two tables , name is student and teacher then i can add the columns with the help of join query :

    1. select student.student_id,teacher_name from teacher inner join students on teacher.teacher_id = student.teacher_id order by student_id ;<br>

    Example ->
    Table names -> users : user1 and user 2 , and Laptop .
    Table 1 ->user1

    1. user_id user_name1
    2. 1 Mukesh
    3. 2 Shubh
    4. 3 Bhoomi

    Table2 -> user2

    1. user_id user_name1
    2. 1 Ayush
    3. 2 Priya
    4. 3 Pranav

    Table3 -> Laptop

    1. Laptop_id user_id Laptop_name
    2. 1 1 Lenovo
    3. 2 2 HP
    4. 3 L1 Asus
    5. 4 L2 Apple

    How to select data from multiple tables give below :
    Query :

    1. select L.Laptop_id , L.user_id , L.Laptop_name , u1.name1 , u2.name2 from laptop as L left join user1 as u1 on L.user_id = u1.user_id left join user2 as u2 on L.user_id = u2.user_id

    Output ->

    1. Laptop_id user_id Laptop_name Laptop_name Laptop_name
    2. 1 1 Lenovo Mukesh Null
    3. 2 2 HP Shubh Null
    4. 3 3 Asus Bhoomi Null
    5. 4 4 Apple Null Ayush

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: