Results 1 to 6 of 6
  1. #1
    markr is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Jan 2018
    Posts
    3

    How to create table where field #2 is exactly the values of field #1 except one to many

    So for simplicity, say I have a table with one field, called ID. It has three records {ABC, DEF, GHI}. How can I use a query to end up with a table with ID and ID2 (new field) which will look like such:
    ID ID2
    ABC ABC
    ABC DEF
    ABC GHI
    DEF ABC
    DEF DEF
    DEF GHI
    GHI ABC
    GHI DEF
    GHI GHI

    In other words - for each ID, there would be a corresponding ID2 equal to all ID values from the original table.

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Welcome to the forum

    think you need to provide a clearer example, ID fields should be unique, but your ID2 field also has duplicates. Also, you have shown your example data, but it not at all clear what the required outcome is

  3. #3
    markr is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Jan 2018
    Posts
    3
    Thanks Ajax. Sorry for not being clear. The table above is the required outcome. ID is a unique field. ID2 is a new field I would create from the query. Essentially where I'm struggling is putting it in that kind of layout where for each ID, there would be an ID2 equivalent to each ID. Original table could be something like:
    ID Sales
    ABC 100
    DEF 500
    GHI 200

    The desired outcome from a query should result in the table below:

    ID ID2
    ABC ABC
    ABC DEF
    ABC GHI
    DEF ABC
    DEF DEF
    DEF GHI
    GHI ABC
    GHI DEF
    GHI GHI

  4. #4
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    This can be achieved by using a "Cross Join".
    Add your table into the query viewer twice, then select the ID field from each one then run the query.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    markr is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Jan 2018
    Posts
    3
    I knew the answer would be very simple but didn't realize it was THAT simple. Why I didn't think of that, I have absolutely no idea! Thanks!

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Looks like what you want is all possible combinations

    so perhaps a Cartesian join (i.e. no join)

    SELECT T1.ID, T2.ID
    FROM myTable T1, MyTable T2
    ORDER BY T1.ID, T2.ID

    Edit: Ah, beaten to it by Minty!

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

Similar Threads

  1. Replies: 6
    Last Post: 07-17-2017, 06:00 AM
  2. Replies: 2
    Last Post: 01-25-2016, 12:21 AM
  3. Replies: 13
    Last Post: 12-23-2013, 09:20 AM
  4. Create a paragraph using Field Values
    By imran688 in forum Access
    Replies: 12
    Last Post: 10-31-2012, 12:04 PM
  5. Replies: 20
    Last Post: 09-12-2012, 06:52 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