假设我的邮件地址是[email protected]收到的时候有时候会显示mailzzzlg<[email protected]>,有时候会显示<[email protected]>,
我把来件的邮件地址保存在表A的mail_from字段里,还有一张联系人表B,有联系人邮件字段b.mailadd
保存的时候都是不带符号的:[email protected]
现在想做一个判断,收到邮件时先判断a.mail_from 是否存在与b.mailadd中,如果存在,则…………,不存在则…………请问这两样的字符串怎么判断是否相同
我把来件的邮件地址保存在表A的mail_from字段里,还有一张联系人表B,有联系人邮件字段b.mailadd
保存的时候都是不带符号的:[email protected]
现在想做一个判断,收到邮件时先判断a.mail_from 是否存在与b.mailadd中,如果存在,则…………,不存在则…………请问这两样的字符串怎么判断是否相同
-----------------------------
<[email protected]>(所影响的行数为 1 行)
-----------------------------
<[email protected]>(所影响的行数为 1 行)
如果是一列 你把'mailzzzlg <[email protected]>'换做列就OK了
-- Author :fredrickhu(小F 向高手学习)
-- Date :2009-06-28 09:53:23
----------------------------------------------------------------
--> 测试数据:[tb]
if object_id('[tb]') is not null drop table [tb]
create table [tb]([col] varchar(33))
insert [tb]
select 'mailzzzlg<[email protected]>' union all
select 'abcdefg<[email protected]>' union all
select 'ddddd<[email protected]>' union all
select 'dddddddddddddd<[email protected]>'union all
select 'tttttttttttt<[email protected]>'union all
select 'sssssssss<[email protected]>'
--------------开始查询--------------------------
select substring(col, charindex('<',col),len(col)) from tb----------------结果----------------------------
/*---------------------------------
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>(所影响的行数为 6 行)
*/