如何在sql的正则表达式中使用OR运算符

时间:2014-09-04 15:31:45

标签: sql

我在正则表达式中使用OR运算符来更新不完全无效的电子邮件的多重集有问题。我试图更新:

 alisonsmith@gmail.com
 bobgraves@hotmail.com
 smithers@yahoo.com 
 011013092949@bony.com
 james@bony.com

 result should look like this:

 alisonsmith@dony.com
 bobgraves@dony.com
 smithers@dony.com
 011013092949@bony.com
 james@bony.com


 I've tried that update procedure for using OR operator like this and it didn't work at all:

 update dbo.Membership   
set Email = left(Email, charindex('@', Email, 0)) + 'dony.com'
OR Email= left(Email, charindex('@', Email, 0)) + 'bony.com'; 

1 个答案:

答案 0 :(得分:0)

这是你想要的吗?:

update dbo.Membership   
set Email = left(Email, charindex('@', Email, 0)) + 'dony.com'
WHERE Email NOT LIKE '%@bony.com'