Results 1 to 4 of 4
  1. #1
    swm28 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2013
    Posts
    2

    Update Query when items do not match another table

    I'm trying to get a query to update values in a table to Null if they do not match values in another table. I usually work in the design view, and I'm not that experienced with SLQ, but I can only seem to get those that do match to update to Null.



    UPDATE Table2 INNER JOIN Table1 ON [Table2].Groups=Table1.Group SET Table1.[Group] = Null;




    This is updating those that match to null, not those that do not match.
    Any help is appreciated.
    Thanks!

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Your code does seem to make much sense. Are you trying to update Table1 or Table2 (you have "Update Table2", then "SET Table1.").

    Can you explain exactly what you are trying to do, using all appropriate Table and Field name references?

  3. #3
    swm28 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2013
    Posts
    2
    Sorry,

    I have two tables. Table 1 has all the raw data. Table 2 is just a list of groups.

    I am trying to update a column (Group Name) in Table 1 to maintain the current value if that value is in Table 2 (column: Group) and to return Null if the value is not in Table 2.


    Basically delete all of the values in Table 1 that do not match a value in Table 2.

    Let me know if you need any more information.

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Wouldn't a simple Select Query between the two suffice? If you use an Inner Join, only matching recods found in both tables are returned.
    It sounds like that might be what you are after.

    If not, maybe you could post a small sample of each table with your expected results. That clarify what you are really after.

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

Similar Threads

  1. Match Table Fields
    By vinsavant in forum Access
    Replies: 1
    Last Post: 01-17-2013, 12:06 AM
  2. Replies: 3
    Last Post: 04-13-2012, 10:39 AM
  3. Replies: 16
    Last Post: 03-13-2012, 03:47 PM
  4. Replies: 5
    Last Post: 03-01-2012, 12:59 AM
  5. Replies: 1
    Last Post: 02-08-2012, 04:50 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