-6

MySQL experts. current data in table. COLUMN NAME IS URL
/abc1/pqr
/abc10/pqr

I need below result ie abc1 and abc10 should be replaced to xyz
/xyz/pqr
/xyz/pqr

How can I do this using replace command as I am unable to use wild card inside replace statement?

Currently I am using below 2 statements but I need a single statement.

UPDATE TABLE_URL
SET url = REPLACE(url, '/abc1/pqr', '/xyz/pqr')  

UPDATE TABLE_URL
SET url = REPLACE(url, '/abc10/pqr', '/xyz/pqr')
Jaydee
  • 4,138
  • 1
  • 19
  • 20
compcc
  • 21
  • 3

1 Answers1

0

Would

UPDATE TABLE_URL SET url = REPLACE(REPLACE(url, '/abc1/pqr', '/xyz/pqr'), '/abc10/pqr', '/xyz/pqr')  

Work for you?

Jaydee
  • 4,138
  • 1
  • 19
  • 20
  • 1 to 10 numbers keep increasing..there is no max value set. so your query wont help. abc1,abc10..............abc111 etc..... – compcc Mar 13 '18 at 16:14
  • Then you are a bit stuck. – Jaydee Mar 13 '18 at 16:19
  • yes.. thats why need stackoverflow experts help. i was thinking of removing numbers substring and then replacing..but not sure how to do. – compcc Mar 13 '18 at 16:39