Using INSERT INTO with 'SELECT' to supply some values but not others (Access 2010)

后端 未结 2 1788
后悔当初
后悔当初 2020-12-19 16:20

I have two tables that look like this:

(\'MASTER_EOD\' TABLE)
ID  SHA1_HEX    ROLE
----------------------------
1   ff34bb03    2
2   eef0a005    1



(\'ROL         


        
2条回答
  •  离开以前
    2020-12-19 16:35

    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.

提交回复
热议问题