我正在使用的查询就是这个。
select orig, term, dial
from rej
where `company = 'goog' and code = '301' and left(term,3) = '011'`
and dial in (select substring(dial, 0, 11) from rej)
orig term dial
4046591010 0112489826790 2489826790
9546674396 0115743064558 5743064558
4844410151 0113537124 3537124
8588763590 0113653 4653
我只需要"拨打"只有10位数字,这个列中的字符不一致,我不需要。 在得到这个之后我需要从术语中移除011 所以最后看起来应该是
orig term dial
4046591010 2489826790 2489826790
9546674396 5743064558 5743064558
提前感谢您的帮助。
答案 0 :(得分:0)
这样的事情:
select orig, stuff(term, 1, 3, '') as term, dial
from rej
where company = 'goog' and
code = '301' and
left(term, 3) = '011' and
dial in (select substring(dial, 0, 11) from rej) and
len(dial) = 10;
答案 1 :(得分:0)
据我所知,您只需要拨号列长10个字符的项目。
select orig, term, dial
from rej
where `company = 'goog' and code = '301' and left(term,3) = '011'`
and dial in (select substring(dial, 0, 11) from rej)
and len(dial) = 10
仅在拨号正好为10个字符时才应选择。 Len Documentation