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).
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).
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.
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!)
thanks for all your help JoeM and R_Badger