Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望替换字段中的一些文本,所以我有以下声明:
UPDATE INVENTORY SET INV_DESCRIPTION = REPLACE(INV_DESCRIPTION, '5 ml', '5ml (1/6oz)')
问题在于该语句将用替换字符串替换诸如“5 ml”“15 ml”“150 ml”等字符串。我希望这个函数能匹配整个单词并且只寻找'5 ml'
您可以添加一个WHERE可以让您非常接近的子句:
WHERE
...Your Current Query... WHERE INV_DESCRIPTION LIKE '5ml%' OR INV_DESCRIPTION LIKE '% 5ml%'
这只会更新以空格开头5ml或5ml前面有空格的记录,这将排除15mlor25ml等。
5ml
15ml
25ml
这是假设 SQL Server。