在表中插入额外的行 [英] Inserting extra rows within table

查看:35
本文介绍了在表中插入额外的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为每个存在的部件号在我的表中添加额外的 2 行.目前我有这样的事情:

I am wanting to add a extra 2 rows to my table for each part number which is present. Currently I have something like this:

+-------------+-----------+---------------+
| item_number | operation | resource_code |
+-------------+-----------+---------------+
| abc         |        10 | kit           |
| abc         |        20 | build         |
| abc         |        30 | test          |
+-------------+-----------+---------------+

表格中还有数百个这样设置的项目.我想根据每个部件号向表中添加 2 行额外的记录.因此,一旦添加了这些,我的数据集将如下所示:

There are hundreds of more items set up like this within the table. I am wanting to add 2 extra lines of records to the table based upon each part number. So once these have been added my data set will look like this:

+-------------+-----------+---------------+
| item_number | operation | resource_code |
+-------------+-----------+---------------+
| abc         | 10        | kit           |
| abc         | 20        | build         |
| abc         | 30        | test          |
| abc         | NULL      | NULL          |
| abc         | NULL      | NULL          |
+-------------+-----------+---------------+

我希望这些新记录暂时为空,稍后再添加.

I am wanting these new records to be blank for now and add to them later.

我正在使用 access 并寻找将这些新记录添加到表中的 sql.

I am using access and looking for the sql to add these new records to the table.

推荐答案

试试这个尺寸:

INSERT INTO my_table
SELECT item_number, NULL AS operation, NULL AS resource_code 
FROM my_table 
GROUP BY item_number
UNION ALL
SELECT item_number, NULL AS operation, NULL AS resource_code 
FROM my_table 
GROUP BY item_number

这篇关于在表中插入额外的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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