5hakir
5hakir

Reputation: 129

update part of string in database when condition meets

enter image description here

This is my database structure. I want to update mobileno column where length(mobileno)!= 13 , and add 88 string before them . Like 017126875493 becomes 88017126875493

Upvotes: 0

Views: 10

Answers (2)

Fahmi
Fahmi

Reputation: 37473

You can try using concat()

UPDATE tablename SET mobileno = concat('88',mobileno)
WHERE length(mobileno) != 13;

Upvotes: 1

5hakir
5hakir

Reputation: 129

Solved it by using concat()

UPDATE passenger.mobileno
SET passenger.mobileno= CASE
   WHEN length(passenger.mobileno)=11 THEN CONCAT("88",passenger.mobileno)
   ELSE passenger.mobileno

Upvotes: 0

Related Questions