Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
2.71/5 (3 votes)
See more:
i have two tables table1 and table.

table1
id name

table2
rank postion

i want to output a table3
table3
id name rank position


the above two table exist in database file,

i want to create table3 in database by using visual studio c#
Posted
Comments
Thanks7872 12-May-14 8:36am    
And whats the issue doing the same? Did you mean you need that table at some point of time?
Peter Leow 12-May-14 8:58am    
what is the relationship between table1 and table2? where is the link?
Emre Ataseven 12-May-14 10:28am    
why do you want to decrease normalization level of your database?

You can't at the present state. Re-look into your tables design, answers these questions:
1. What is the primary key for each table;
2. How do the 2 tables related (linked), i.e. primary key <=> foreign key
Refer: Relational_Database_Design[^]
 
Share this answer
 
v2
Your table2 needs to have a foreign key id to table 1. I would have to guess on the limited information you provided that table 2 has a field named something like table1_id. Then you can just do this:

SQL
SELECT table1.id, table1,name, table2.rank, table2.position
FROM table1 
LEFT JOIN table2 ON table1.id = table2.table1_id


You need to have a relationship between the tables or else you end up with some cross join that would likely be meaningless data.
 
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