如果您有电子邮件地址
you.late.you@asdf.com
you_late_you@asdf.com
如果使用 sql 代码有 2 个点/下划线,如何启用计数?
如果您有电子邮件地址
you.late.you@asdf.com
you_late_you@asdf.com
如果使用 sql 代码有 2 个点/下划线,如何启用计数?
select len('you.late.you@asdf.com') - len(replace('you.late.you@asdf.com', '.', ''))
这会给你想要的结果。
DECLARE @str VARCHAR(1000)
SET @str = 'you.l_ate.you@as_df.com'
SELECT (LEN(@str)- LEN(REPLACE(@str ,'.' ,'')))+(LEN(@str)- LEN(REPLACE(@str ,'_' ,'')))
答案:5
我想他想数@之前没有点的字母:
declare @myEmail varchar(50)
set @myEmail = 'you.late.you@asdf.com'
declare @mySearch varchar(50)
set @mySearch = SUBSTRING (@myEmail,0 , PATINDEX( '%@%',@myEmail))
select (LEN(REPLACE(@mySearch, '.', '')))
如果要计算具有两个.
or的行数_
,可以执行以下操作:
select count(*)
from mytable
where left(email, charindex('@', email)) like '%[._]%[._]%'
left
andcharindex
用于忽略域名(将有).
。
select
length(substr('you.late.you@asdf.com',1,INSTR('you.late.you@asdf.com','@',1))) -
length(replace(substr('you.late.you@asdf.com',1,INSTR('you.late.you@asdf.com','@',1)), '.', ''))
from dual