将数据从一个表复制到另一个表并添加其他数据 [英] Copy Data From One Table To Another AND Adding Additional Data

查看:125
本文介绍了将数据从一个表复制到另一个表并添加其他数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库中有一个临时表和一个常规表.列名和类型相同,除了常规表中有一个额外的字段.我正在尝试编写一个查询,该查询将信息从temp表复制到常规表中,并将数据添加到一个查询中的additional字段中.

I have a temp table and a regular table in my database. The column name and types are identical, except the regular table has an extra field. I am trying to write a query that copies the information from the temp table into the regular table and adds data into the addition field all in one query.

我了解如何将列从一个表复制到另一个表(例如,INSERT INTO TABLE 1(col 1,等等.)SELECT TABLE2),但是我该怎么做,然后为新字段添加一个值?

I understand how to copy columns from one table to another (e.g. INSERT INTO TABLE 1 (col 1, etc..) SELECT TABLE2), but how do i do this AND then add in a the value for the new field?

感谢您的帮助.

推荐答案

 INSERT INTO TABLE1 (col 1, col2,..., the_extra_col) SELECT *, NULL from TABLE2

 INSERT INTO TABLE1 (col 1, col2,..., the_extra_col) SELECT *, the_default_date_here from TABLE2

这篇关于将数据从一个表复制到另一个表并添加其他数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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