I have two tables namely Table1 and Table2 Now in table 1 i have following fields EmpNo DOB Age and

Posted by Sp under ASP.NET on 8/1/2012 | Points: 10 | Views : 911 | Status : [Member] | Replies : 6
I have two tables namely Table1 and Table2
Now in table 1 i have following fields
EmpNo
DOB
Age

and in Table2 i have the following field
Sno
EmpNo
Skills

Now i have to write a query which helps in cretae a datatable with following field:
EmpNo
DoB
Age
Skills




Responses

Posted by: prashant12-7256 on: 8/1/2012 [Member] Starter | Points: 25

Up
0
Down
use inner join to join two tables like this :

Select a.EmpNo ,a.DoB ,a.Age,p.Skills from table1 As C

INNER JOIN
table2 As p
ON
a.EmpNo = P.EmpNo


To learn more on joins and inner join got to following link :
inner join :
http://www.w3schools.com/sql/sql_join_inner.asp

sql join :
http://www.w3schools.com/sql/sql_join.asp



Sp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 8/1/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Hi...
Try this

SELECT     Table_1.EmpNo, Table_1.DOB, Table_1.Age, Table_2.Skill

FROM Table_1 INNER JOIN
Table_2 ON Table_1.EmpNo = Table_2.EmpNo


Sp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nksingh420 on: 8/1/2012 [Member] Starter | Points: 25

Up
0
Down
select t1.Empno,t1.dob,t1.age,t2.skill into table3 from table1 as t1,table2 as t2 where t1.Empno=t2.Empno

Sp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sivakumar.S on: 8/1/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

Try this below query,


Select A.EmpNo, A.DOB,A.Age,B.Skills from Table1 A
Inner join Table2 B on A.EmpNo = B.EmpNo

siva

Sp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sf_Hussain786 on: 8/1/2012 [Member] Starter | Points: 25

Up
0
Down
http://www.sqlbook.com/SQL/INNER-JOIN-37.aspx

sf_hussain786

Sp, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 8/1/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Hi.. @Sp
Plz Mark as answer, if post helps u.

Sp, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response