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
    • 116
    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 :

    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

     user_id            user_name1         
        1                 Mukesh
        2                 Shubh
        3                 Bhoomi
    

    Table2 -> user2

    user_id            user_name1         
         1               Ayush
         2               Priya
         3               Pranav
    

    Table3 -> Laptop

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

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

    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 ->

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

 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: