I have two tables that look like this:
(\'MASTER_EOD\' TABLE)
ID SHA1_HEX ROLE
----------------------------
1 ff34bb03 2
2 eef0a005 1
(\'ROL
You can substitute a DLookup
expression for your SELECT role_num ...
query.
SELECT role_num FROM role_index WHERE role_name='Follow Up'
DLookup("role_num", "role_index", "role_name='Follow Up'")
Use that DLookup
in your INSERT
.
INSERT INTO master_eod
(
sha1_hex,
[role]
)
VALUES
(
'ef03ff03',
DLookup("role_num", "role_index", "role_name='Follow Up'")
);
I enclosed role
in square brackets because it is a reserved word.
Try doing it in the most standard way in SQL, by using the SELECT
as the whole source in the INSERT
instead of just a single column sub-query:
INSERT INTO master_eod ( sha1_hex, role )
SELECT 'ef03ff03', role_num FROM role_index WHERE role_name='Follow Up' ;
Note that you must ensure that such a query (the SELECT
alone) returns just a single row, otherwise you would end up inserting many rows at once in a single go, one for each role_num found (which may or may not be desirable).