sql数据库表合并操作 [英] sql database tables merge operation
问题描述
即时开发asp.net web应用程序,用sql数据库
i制作2个名为reg的表,userverify
在reg表中有一些列,如用户名,密码等,..
和userverify表有secretcode,securityques,securityans(3cloumns)。
i希望将单个表中的两个表合并为userAcc.it应该有用户名,密码,安全字典,密码,安全人员......我是新手为sql数据库和c#求助我先谢谢。
hi , im developing asp.net web apps,with sql database
i make 2 tables named reg,userverify
in reg table have some columns like username,password etc,..
and userverify table have secretcode,securityques,securityans (3cloumns).
i want to merge the two tables in single table like userAcc.it should have username,password,securityques,secretcode,securityans.... im newbie for sql database and c# help me adv thanks.
推荐答案
看一下以下链接:
sql_join [ ^ ]
sql-joins的beginner-sql-tutorial [ ^ ]
加入SQL [ ^ ]
SQL Joins [ ^ ]
Take a look at following links:
sql_join[^]
beginner-sql-tutorial for sql-joins[^]
Joins in SQL[^]
SQL Joins[^]
您是否创建了包含所需列的表???创建表后,使用以下查询从reg插入数据,userverify table to userAcc table:
Did you create table having all columns you want??.. After creating table, use the following query to insert data from reg, userverify tables to userAcc table:
insert into [userAcc](username,password,etc)
select username,password,etc from reg
insert into [userAcc](secretcode,securityques,securityans)
select secretcode,securityques,securityans from userverify
你需要在两个表中都有一个共同的符号(reg& amp; userverify)加入他们。否则,加入将是所有可能的组合。在这种情况下,您可以使用上面的查询,或者您需要创建两个表共有的列。
在此处阅读有关JOIN的更多信息:
SQL联接 [ ^ ]
http://msdn.microsoft.com/en-IN/library/ms191517(v=sql.105).aspx [ ^ ]
如果您觉得有用,请标记。
You need a common cloumn in both the tables(reg & userverify) to join them. Otherwise join will be all possible combinations. In this case you can use above query or u need to create a column common to both tables.
Read more about JOIN here:
SQL Joins[^]
http://msdn.microsoft.com/en-IN/library/ms191517(v=sql.105).aspx[^]
Mark it if you find this helpful.
这篇关于sql数据库表合并操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!