简体   繁体   English

如何将此值插入此表

[英]How to insert this value into this table

I have these 2 tables in Ms Access: 我在Ms Access中有这两个表:

Items
RowID, Value

and

ItemRange
Value, RowIDStart, RowIDEnd

I want to insert a Value in Items table with a Value in ItemRange table within the range of RowIDStart and ROwIDEnd 我想在RowIDStart和ROwIDEnd范围内的ItemRange表中插入Value in Items表

How do you do this in SQL? 你是如何在SQL中做到这一点的? I know how programmatically via Cursor (Open/Fetch) but not sure in pure SQL. 我知道如何通过Cursor(Open / Fetch)以编程方式,但在纯SQL中不确定。

Not sure if I got your question right 不确定我的问题是否正确

but try this insert statement 但尝试这个插入语句

INSERT INTO Items (RowID, Value)
SELECT RowIDStart, Value
FROM ItemRange

OR this one if you want to get both tables 如果你想得到两个表,或者这个

SELECT ItemRange.RowIDStart, ItemRange.RowIDEnd, Items.Value
FROM ItemRange INNER JOIN Items 
ON Items.RowID >= ItemRange.RowIDStart AND Items.RowID <= ItemRange.RowIDEnd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM