问题
I want to delete a certain string in a cell in MS Access, whether in a column or in the whole table. I know that I can do this using plain old Find and Replace but in this case it is not economical for my thousand-row table.
For example,
- remove all
Unknown
values from all columns. - remove the string "dollars" from the values in column
price
ie. if the cell contains "34 dollars", it will just be "34".
Can this be done in SQL and how?
回答1:
Assuming your query will run within an Access session, the second goal is easy. You can Replace
dollars with a zero-length string.
UPDATE YourTable
SET price = Replace(price, 'dollars', '');
You could use the same strategy for the first goal, but may decide it makes more sense to examine the datatypes of the table's fields and only UPDATE
those which are text or memo.
来源:https://stackoverflow.com/questions/21118011/remove-a-string-inside-a-cell-in-ms-access