I have two columns like this. (TC_NO 开发者_如何学Gois 11 character, VER_NO is 10 character)
TC_NO VER_NO
19262512794 1926251279
31124177286 1111111111
31067179194 2222222222
65617278204 6561727820
31483188084 0000000000
What i want is, finding VER_NO's first 10 character is the same TC_NO's first 10 characters..
For example for this table the result should be:
TC_NO VER_NO
19262512794 1926251279
65617278204 6561727820
How can I do that in Oracle?
select *
from MYTABLE
where substr(TC_NO,1,10) = VER_NO
Assuming you dont have nulls.
select *
from MYTABLE
where substr(TC_NO,1,10)=substr(VER_NO, 1, 10);
If you have nulls and you want them to be equal.
select *
from MYTABLE
where substr(NVL(TC_NO, '-'),1,10)=substr(NVL(VER_NO, '-'), 1, 10);
If you have nulls and you dont want them to be equal.
select *
from MYTABLE
where substr(NVL(TC_NO, '-'),1,10)=substr(NVL(VER_NO, '|'), 1, 10);
精彩评论