SQL替换函数
我想替换 WHERE 语句中第一个字符为 S 的字符,
现在我所拥有的只有以下内容:
WHERE i1.CODE = REPLACE(i2.CODE, 'S', 'U')
但这会将所有 S 替换为 U。我只是希望将 S 替换为 U 仅当 S 是第一个字符时
谢谢!
I would like to replace characters within my WHERE statement that have the first character of S,
right now all i have is the following:
WHERE i1.CODE = REPLACE(i2.CODE, 'S', 'U')
but this would replace all S's with U's. I just wish to replace the S with a U only when the S is the first character
thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
另一种选择:
正如 ErikE 所建议的,您还可以用任意大的静态值替换 Len(i2.Code) ,这可能会稍微提高速度。
Another alternative:
As ErikE suggested, you can also replace
Len(i2.Code)
, with an arbitrarily large static value which might make a small speed improvement.免责声明:这真的非常非常难看,但我认为它有效。
DISCLAIMER: This is really, really ugly, but I think it works.