views:

410

answers:

2

Rookie question I know.

I have a table with about 10 fields, one of the fields is a category field. I need this field to exist because of the multiple types of categories. However, one category in this field is wrong and is duplicating results.

So can I delete all records in the table that have "Type320" in the CatDescription field, and how? I want to keep eveerything else as it is in this table; just need to get rid of the records that have that that in that one field

Thanks very much!

EDIT: Thanks for the answer, I did not know how to do this so this is very helpful

However, this is more complicated than I thought. The raw data that I am supplied carries these duplicate records (only duplicate in certain circumstances but they are easy to isolate). This raw data is given to me on a monthly basis in several spreadsheet forms.

It all relates to these ID numbers, and has like 10 fields (xls columns). As I said before one of these is the Category Description field (sorry, this is not a lookup) In certain places this records automatically duplicates itself on output because in the database this comes from, it has to have this sub category for one particular "type"

So....every time there is a duplication, every single bit of information in all fields are exactly the same, with the exception of this CatDescription (one is Type320, and the duplicated record type is "Type321"). However, there are some instances where Type321 is valid on it's own (in which case there is no matching data row with a Type320 catdescription). By matching I mean all data in all fields of a particular record.

A very clear absolute of this is if all fields (data within) of a record with Type320 CatDescription, matches all fields (data within) a record with Type321 CatDescription, then I can delete that record containing Type321 CatDescription. This is true because this is the only situation where this duplication occurs, normally not all of this should match.

This allows all unique records with Type320 and Type321 data (that does not match exactly) to stay; just a it should. This makes sense to me (and hopefully you too :/) but can it be done, and how?

thanks because this is way over my head. I would rather know how to do it in access, but an xls solution is equally as appreciate. heck i would do it in ppt if it would get the job done! :)

+5  A: 

I would try with one of these two querys:

DELETE FROM table WHERE CatDescription LIKE '%Type320%';
DELETE FROM table WHERE CatDescription LIKE '*Type320*';

That because the Access database engine could be using * (ANSI-89 Query Mode e.g. DAO) instead of % (ANSI-92 Query Mode e.g. OLE DB/ADO) for the wildcards.

Alternatively, this regardless of ANSI Query Mode:

DELETE FROM table WHERE CatDescription ALIKE '%Type320%';

Note the Access database engine's ALIKE keyword is not officially supported.

Jhonny D. Cano -Leftware-
Jhonny is right. Remember though that like is pretty expensive - not that it matters if your table is small. If the field only has Type320 in it use "WHERE CatDescription ='Type320'"
Praesagus
I don't get why the answer uses LIKE at all. There's no indication in the question that a partial match is needed at all.
David-W-Fenton
+1  A: 

Does the CatDescription field look to another table? Is it a a query of those tables that creates what you call duplicate results?

If so, be careful about blaming the table that has CatDescription. Check the look-up table to see if Type320 is found there in duplicate.

If you don't have the problem isolated correctly, then you're likely to delete good records while not fixing the problem.

Smandoli