Results 1 to 2 of 2
  1. #1
    gmaster is offline Advanced Beginner
    Windows 8 Access 2010 32bit
    Join Date
    May 2014
    Posts
    32

    Query insert with too many conditions...?

    Hi everybody! Today i'm facing this problem, i'm trying to write a query that:
    - select from a tab (called "FC") all the records that have a YES/NO field (called "Transfer") on YES
    - since this tab has a field ("Id_paz") that is FK on another tab ("Pazienti", where the corresponding PK is "CodFisc"), append the corresponding records (actually, just some fields i need) from the "Pazienti" tab into another called "Pazienti_BB"
    - but BEFORE THAT, it should check that in "Pazienti_BB" there aren't already records equal to those one it is going to add, and in that case skip to the following record (in order to avoid error messages, since CodFisc in PK also in Pazienti_BB)
    Now, i wrote a query that cover the first two points:
    INSERT INTO Pazienti_BB
    SELECT CodFisc AS CodFisc, Cognome AS Cognome, Nome AS Nome, Genere AS Genere, Data_nascita AS Data_nascita
    FROM Pazienti
    WHERE CodFisc IN (SELECT Id_paz
    FROM FC WHERE FC.Transfer = TRUE);


    But for the third point i'm clueless.......any idea? Have i explained myself??
    Thanks!!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    This appears to be duplicating data.

    I suppose you can do a Find Unmatched query and somehow use that as criteria for the IN operator. Or maybe a DLookup but domain aggregates can be very slow in a query.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. INSERT query: insert new data only
    By drh in forum Access
    Replies: 2
    Last Post: 04-04-2014, 05:31 PM
  2. Replies: 6
    Last Post: 02-13-2011, 06:02 PM
  3. Update Query - Multiple SETS and WHERE conditions
    By jasonbarnes in forum Queries
    Replies: 26
    Last Post: 12-15-2010, 01:08 PM
  4. Query result based upon two field conditions
    By diane802 in forum Access
    Replies: 35
    Last Post: 01-08-2010, 06:31 PM
  5. Query on multipl conditions.
    By Goldenbird in forum Queries
    Replies: 0
    Last Post: 06-28-2009, 11:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums