[英]SQL SELECT or INSERT INTO query
I'm working with SQL Server 2000. I need to take the results from one column ( VALIMIT
) and insert them into another column ( VALIMIT2012
) in the same table ( lending_limits
). 我正在使用SQL Server 2000.我需要从一列(
VALIMIT
)获取结果并将它们插入到同一个表( lending_limits
)中的另一列( VALIMIT2012
)中。
My question is do I need to do a SELECT
query first, or do I just start with an INSERT INTO
query and what the proper syntax would be for the INSERT INTO
query. 我的问题是,我需要做一个
SELECT
第一查询,还是我只是有启动INSERT INTO
查询,什么正确的语法是对INSERT INTO
查询。
Neither. 都不是。 You don't insert columns, you insert rows, so what you want is an
update
: 您不插入列,插入行,所以您想要的是
update
:
update SomeTable
set VALIMIT2012 = VALIMIT
Note: It looks like you have one column per year, which is bad database design. 注意:看起来每年有一列,这是糟糕的数据库设计。 If you have different data for each year, you should put that in a separate table, so that you get the year as data, not part of the column name.
如果每年有不同的数据,则应将其放在单独的表中,以便将年份作为数据,而不是列名称的一部分。
UPDATE TableName SET VALIMIT2012 = VALIMIT
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.