Results 1 to 4 of 4
  1. #1
    scorpy is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2015
    Posts
    2

    update cells from table 2 for all blanks in table 1

    Hi guys,

    I am in a complicated situation where i was given 50 tables with 45 column in each table and told to merge them into a single table. Each table has over 10,000 records and merge has to be done based on the field S#NO. I have attached a sample with two tables in which the non blank fields from both table should be merged into a new table.

    Is there any way to accomplish the merge?
    Attached Files Attached Files

  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
    52,929
    What do you mean by 'merge'? Do you mean you want to UPDATE the data from 49 tables into Table1? Do you want to normalize data structure?

    Table1 has data in records 1 thru 4 and Table2 has data in records 6 thru 8. Can more than one table have data in the same S#NO?

    Show example of the result you want to achieve.

    A UNION query might get you what you want.


    Advise not to use spaces and special characters/punctuation (underscore is exception) in naming convention.
    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
    scorpy is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2015
    Posts
    2
    By means of merge i meant i have to update the data from all tables to be made into a single table.(only data should be merged and "blank" should not replace the "cell which previously had data")

    Data in these tables will be just a Yes, so there is no problem in overwriting the data. More than one table may have data for same S#No.

    I never used Union Query before and i have attached the desired output table with this post.

    Thanks for your time.
    Attached Files Attached Files

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    So if table 5 and table 17 both have data for the same S#No, the data is the same in both records for all fields? If one has Y in Commercial, they both do? Oh well, I think not important.

    Example UNION query:

    SELECT * FROM table1
    UNION SELECT * FROM table2
    UNION SELECT * FROM table3
    ....;

    Up to 50 SELECT lines allowed. There is no wizard or builder for UNION, must type into SQL View window.

    UNION will not allow duplicate records (UNION ALL will). http://www.w3schools.com/sql/sql_union.asp

    The UNION query can be used as data source for another query to refine the data. Next query would be an aggregate:

    SELECT [S#No], Max(Commercial) AS MaxCom, {do Max on each field} FROM UnionQuery GROUP BY [S#No];

    Now this dataset should be the merged set you want. Run a MAKE TABLE sql action to create native table.


    How often will this merge need to take place? Is this a one-time event?


    Alternatively, run 50 UPDATE sql actions.
    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. Inactive Cells (rows and columns) in Split Form table
    By SyntaxSocialist in forum Forms
    Replies: 3
    Last Post: 04-17-2013, 03:18 PM
  2. Replies: 6
    Last Post: 06-14-2012, 03:39 PM
  3. Form To Table - To Many Cells
    By LOUM in forum Forms
    Replies: 3
    Last Post: 05-03-2012, 02:21 PM
  4. Fill in blanks from another table
    By HectorH in forum Queries
    Replies: 1
    Last Post: 08-26-2011, 05:13 PM
  5. SQL Update with blanks
    By Tyork in forum Programming
    Replies: 1
    Last Post: 12-17-2010, 10:12 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