Search code examples
sqldatabaseinsertsubstrdigit

Making a table which is difference of 2 table by eliminating first char


I have 2 table as ebl_old and ebl. Both table has 1 column called imei. I have also an empty table called ebl_test. I want to add the rows which exists in ebl_old and not exists in ebl into ebl_test.

But my problem is: the data format in ebl_old and ebl is 15digit (starting with 0 and like 0xxxxxx...) and i want the data which will be added into ebl_test has format 14 digit (no 0 at the beggining)

when i execute :

insert into ebl_test
select * from ebl_old  a where not exists (select null from ebl  b where a.imei=b.imei)

it is adding the data with 0 at the beginning of them. How can eliminate that zero and make the data 14 digit instead of 15 digit ?


Solution

  • insert into ebl_test
    select example1,
           example2,
           Substring(example3,1,14) --Lose the first character of example 3
    from ebl_old a 
    where not exists (select null from ebl  b where a.imei=b.imei)