Friday, October 15, 2010

Join More than one table in SQL (SQL JOINS)

Here i am showing how to join more than one table with another table
For Example I have 3 Tables data as the following
1.student_data
             |_stdid
             |_studentname
2.student_result
             |_studentId
             |_Sub1Marks
             |_Sub2Marks
3.student_personnalinfo
              |_std_id
              |_std_address
              |_std_cell

EX: I need to get all the information in a single sql statement which is stored in 3 different  table
Sol: Sql query :

select std.studid,std.studentname,stdr.Sub1Marks,stdr.Sub2Marks,stdinfo.std_address,stdinfo.std_cell from student_data as std
join student_result as stdr on studentId=std.studid
join student_personnalinfo as stdinfo on std_id=studentId

Result of the Above Query is :






I hope it will helps you while you join more than one table in sql

No comments:

Post a Comment