Help to add a "0" at the beggining of all the datas in a column


I'm currently learning SQL and am a begginer and need a bit of help on a topic.

I've got a database with 2 different tables and with a phone number as a key.
My issue is that on one of my table, the phone number is written with a "0" at the beggining and on the other one without it so I can't connect the two tables.
I put a screenshot of the column attached.
How can I add a "0" at the beggining of the column "inoming_number"?

Thank you in advance,



1 Like

Thank you but I'm a real begginer, can you explain my step by step how can I add the "0", the formula and all the steps necessary please ?

I am not familiar with Postgre; this is a Microsoft SQL Server forum. But the following should work:

  1. If you want to keep the data in the table unchanged, but get the incoming_number with a 0 prefixed when you select from the table, do this:


  2. If you want to modify the data in the table, do this.

UPDATE yourTableName SET incoming_number = '0'+incoming_number;


I totally missed that :frowning:

Assuming table "calls" are without zero and table "clients_crm" is with zero and column name in both tables are "incoming_number":

select * /* <--- the fields you want to show */
  from calls as a
       inner join clints_crm as b
               on b.incoming_number='0'||a.incoming_number
1 Like

Thanks for helping

I finally managed it by using the "create view"