Results 1 to 7 of 7
  1. #1
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    409

    Union query unique values only in some field

    hi,
    i want to merge two queries using a union query; i want unique value but not for all the record, just some field must not match

    FIELDS

    NAME/SURNAME/POSITION/COMPANY/DATE




    i want to merge every record from query 2 to query 1 but only records that have no match for NAME/SURNAME/POSITION/COMPANY field, the DATE field can be different

    So if i have:

    query 1
    john wayne gunman westside 2/2/20

    query 2
    john wayne gunman westside 3/3/19


    the record in query 2 (john wayne gunman westside 3/3/19) should not addedd in union query

    thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,967
    A UNION won't work that way. Different dates make records distinct. Why include date field?

    Build the UNION then use it in an aggregate query to get Max([datefield]) or Min([datefield]) for each person.

    So why do you even have two queries that need UNION? What is the source data?
    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.

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    If you really have fields names "Name" and "Date", you are asking for problems. "Name" and "Date" are reserved words in Access and shouldn't be used for object names.

    Problem names and reserved words in Access

  4. #4
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    409
    sorry they are not real names of my fields, i had to specify it
    Quote Originally Posted by ssanfu View Post
    If you really have fields names "Name" and "Date", you are asking for problems. "Name" and "Date" are reserved words in Access and shouldn't be used for object names.

    Problem names and reserved words in Access

  5. #5
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    409
    my source data are linkedin exports, that i use a lot

    so the problem is that i have two accounts and persons in both account, and i want to import just one of them; i export in the same time both accounts data, so some people are doubled but since i made the contact in different days the record will be the same for all field except the field "date", that's the date of connection

    Quote Originally Posted by June7 View Post
    A UNION won't work that way. Different dates make records distinct. Why include date field?

    Build the UNION then use it in an aggregate query to get Max([datefield]) or Min([datefield]) for each person.

    So why do you even have two queries that need UNION? What is the source data?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,967
    Did you try my suggestion?
    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.

  7. #7
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    409
    yes i'm trying looks like is the good one.
    i'm figuring out to make it with few steps cause i want to pack everything in my vba.
    if i have not problems i just mark this as solved, thanks

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

Similar Threads

  1. Replies: 13
    Last Post: 05-04-2020, 09:55 AM
  2. Replies: 22
    Last Post: 11-28-2015, 06:14 PM
  3. Union Query Order By Specific Row Values
    By Dormie in forum Queries
    Replies: 3
    Last Post: 02-18-2015, 10:42 AM
  4. Replies: 2
    Last Post: 08-11-2014, 11:01 AM
  5. Showing zero values in a Union Query
    By coach32 in forum Queries
    Replies: 5
    Last Post: 09-06-2011, 07:46 AM

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