+ 2

I have some questions about replace method

i have sample number like 083232432111 and i want change two digit number from left "08" become "628".. can all of you help me solve this? i new in sql.

20th Feb 2017, 2:54 PM
ambang rizky
ambang rizky - avatar
9 Respuestas
+ 5
there might be command in SQL too but you can do that by PHP too, as $number=//number fetched from the database. $number_replace=(string)$number; str_replace("08","628",$number_replave,1); mysqli//run SQL to update the changed number. for whole row iterate over the query array with for loop
20th Feb 2017, 4:17 PM
Sandeep Chatterjee
+ 1
hey makhija, it's just number and i just want to change two digits number from left "08" become "628".. example 083232432111 become 6283232432111 i just need to know how SQL working bout it..
20th Feb 2017, 3:12 PM
ambang rizky
ambang rizky - avatar
+ 1
i know that method.. but how if i have many number like 0836373727111 0817261818183 0827362718372 like that, i just want change "08" become "628" and my column names is b_number.. i have over 1000 number in b_number column with "08" from left, and i want changed all of it become "628"..
20th Feb 2017, 3:19 PM
ambang rizky
ambang rizky - avatar
0
man
20th Feb 2017, 7:25 PM
choze
choze - avatar
0
SELECT REPLACE(083232432111,08,628) FROM DUAL;
26th Feb 2017, 10:28 AM
Ashish Shakya
0
SELECT REPLACE (column_name, 08, 628 ) FROM table_name; All '08' will be replaced by 628. If you want to only change starting 08 digits then include SUBSTR in this query.
26th Feb 2017, 10:40 AM
Ashish Shakya