質問

I have a table with part numbers. sometimes people put xxx at the end of the part number when they want to include all of the different possible endings (a lot like the wildcard ### in Access). How do I write a query that will give me all of the part numbers and replace anything ending in xxx with ###?

So if my table has:

1234
1235-xxx
1236

How do I write a query that will give me:

1234
1235-###
1236
役に立ちましたか?

解決

In Access, you can use the replace function to change some text into some other text: http://office.microsoft.com/en-ca/access-help/replace-function-HA001228898.aspx

Together with a select statement and the iif function to choose the exact rows that need the replacement, it's a fairly simple operation:

select
  iif(
    part_num like '*-xxx'
  , replace(part_num, '-xxx', '-###')
  , part_num
  )
from my_table
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top