从一个表中选择数据,然后插入到另一个表中 [英] Select Data from one table and insert into another table

查看:78
本文介绍了从一个表中选择数据,然后插入到另一个表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有两个表SQL数据库,一个用户表和一个user_events表.单击按钮时,我需要从用户表中检索用户ID并插入到user_events表中的列中. .如果有人建议我替代此方法,我将不胜感激.

Hi,

I have two tables the SQL database, a user table and the user_events table .On button click i need to retrieve userid from user table and insert into a column in the user_events table.Can anyone tell me how to achieve the task on asp button click. I would be thankful if anybody suggest me an alternative for this.

推荐答案

尝试一下:
Try this :
INSERT INTO UserEvents(UserId)
SELECT UserId
FROM User
WHERE UserName='XXX'



看看:



Have a look at :http://blog.sqlauthority.com/2007/08/15/sql-server-insert-data-from-one-table-to-another-table-insert-into-select-select-into-table/[^]
this might help you


这可能是实现此目的的一种方法:

This could be one way to do this:

SELECT *
INTO Persons_Backup
FROM Persons


这篇关于从一个表中选择数据,然后插入到另一个表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆