Insert INTO NOT EXISTS SQL access

后端 未结 3 1081
失恋的感觉
失恋的感觉 2020-12-21 12:05

I am trying to insert records from another table into a table in Access using sql. I have pasted the statement below. I want to insert the records that exist in ImportMetr

3条回答
  •  悲&欢浪女
    2020-12-21 12:47

    You need to correlate your NOT Exist query with the ImportMetricsIDs01262015 table

    This code is on the assumption that FormularyID is the key in both the tables.

    INSERT INTO ShouldImportMetricsIDsTable (
        [Formulary ID]
        ,[Market Segment]
        )
    SELECT ImportMetricsIDs01262015.[Formulary ID]
        ,ImportMetricsIDs01262015.[Market Segment]
    FROM ImportMetricsIDs01262015
    WHERE NOT EXISTS (
            SELECT *
            FROM ShouldImportMetricsIDsTable
            where ShouldImportMetricsIDsTable.[Formulary ID] = ImportMetricsIDs01262015.[Formulary ID]
            );
    

提交回复
热议问题