本文介绍了从一个表中选择数据,然后插入到另一个表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个表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.
推荐答案
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
SELECT *
INTO Persons_Backup
FROM Persons
这篇关于从一个表中选择数据,然后插入到另一个表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!