0

I am trying to delete/replace all cells of a field in MS-Access 2016 which contain a certain string (in my case a "<" & ">").
This would be no problem if only the string itself needed to be deleted/replaces (Remove a string inside a cell in MS Access) but I would like to delete/replace the entire cell if the criteria is met. Example:
Field

<br>I like food
I also like food
Nice to meet you <br>

Result:


I also like food

As you can see, the number of characters as well as the number of words and blanks vary from cell to cell. The only thing they have in common is "<" & ">".


Thank you in advance!

Mcgroger
  • 67
  • 6

3 Answers3

2

I expect by saying cell you mean the field of a table. So you want to set fields of a table to null if they contain a < and a >.

So this is what you want:

Update YourTable Set YourField = Null Where YourField Like '*<*' And YourField Like '*>*' 

If you explicitly want to set the field to an empty string use this:

Update YourTable Set YourField = '' Where YourField Like '*<*' And YourField Like '*>*' 
AHeyne
  • 3,377
  • 2
  • 11
  • 16
1

This will return records that do not contain a < character.

SELECT MyText
FROM Table1
WHERE INSTR(MyText, "<")=0  

this will delete the whole record where MyText contains a <:

DELETE *
FROM Table1 
WHERE INSTR(MyText, "<")>0  

Probably better to use the LIKE method that @UnhandledException uses rather than INSTR.

Darren Bartrup-Cook
  • 18,362
  • 1
  • 23
  • 45
0

something like this:

update tablename
set cell = ''
where contains(cell,'<') and contains(cell,'>')

if contains is not supported you can use

where cell like '*<*' and cell like '*>*'
Hogan
  • 69,564
  • 10
  • 76
  • 117