Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
I have two tables in SQL . one has 2000 records and another has 20. I would like to relate these two tables into one.
Posted
Comments
_Asif_ 22-Jan-16 8:12am    
And what have you tried?

1 solution

You need to use a JOIN, assuming the two tables have a field in common, such as an id. This is very basic SQL.

For example:
SQL
SELECT t1.id, t1.field1, t1.field2, t2.field1, t2.field2
FROM table1 t1
LEFT JOIN table2 ts ON t1.id = t2.id


That will get all the records. If you want to go into a new table I suggest creating the table first and then you could just do an insert using the select statement above.
 
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