Results 1 to 4 of 4
  1. #1
    Jerseynjphillypa is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Apr 2012
    Posts
    83

    delete query with exceptions


    I have a two fields call City and State in a table.

    I want to delete all the rows that are in NJ (State Field), expect if any of the city are Princeton or Trenton (City Field).

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    First create a Select Query to select all the records you wish to delete.
    To do this, add criteria to your State field of "NJ",
    and add criteria to your City field of Not In ("Princeton","Trenton")

    Confirm that it is returning all the records you wish to delete.
    Then change your query to a Delete Query and run.

  3. #3
    R_Badger is offline Knows a few tricks
    Windows XP Access 2003
    Join Date
    Feb 2012
    Location
    Suffolk, UK
    Posts
    262
    Review
    http://www.w3schools.com/sql/sql_delete.asp

    You are probably looking for something like:

    DELETE * FROM [TABLE_NAME] WHERE [STATE]='NJ' and [CITY]<>'Princeton' and [CITY]<>'Trenton'

    Be careful with this, as these cannot be undone (in other words create a backup first to make sure it does what you want!)

  4. #4
    Jerseynjphillypa is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Apr 2012
    Posts
    83
    thanks for all your help JoeM and R_Badger

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

Similar Threads

  1. Replies: 2
    Last Post: 01-24-2012, 02:16 PM
  2. Trying to Delete record using delete query
    By MooseOTL in forum Access
    Replies: 13
    Last Post: 10-04-2011, 02:30 AM
  3. Replies: 11
    Last Post: 03-30-2011, 01:08 PM
  4. Delete Query
    By stan.chernov@gmail.com in forum Queries
    Replies: 3
    Last Post: 09-17-2010, 04:10 PM
  5. Delete Query
    By jgelpi16 in forum Queries
    Replies: 2
    Last Post: 09-14-2010, 12:16 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