Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have populated two datatables with several fields and several rows.

i.e.:
datatable1
ID Name lastname
1 john sander
2 rob hens
...

datatable2
ID job address
2 teacher somewhere

Question:
I would like to end up with a datatable as follows:
ID Name LastName Job Address

How is this done please?
Thanks
Posted
Comments
[no name] 26-Sep-12 6:46am    
is the id column is used as foreign key in other table
arkiboys 26-Sep-12 6:53am    
Both tables have a column called ID which is unique for both

1 solution

SQL
SELECT datatable1.ID, datatable1.Name, datatable1.LastName, datatable2.Job, datatable2.Address
FROM datatable1
INNER JOIN datatable2
ON datatable1.ID=datatable2.ID
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900