View Single Post
Old 09-16-2021, 01:18 PM  
k0nr4d
Confirmed User
 
k0nr4d's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Poland
Posts: 9,228
Your description is still incredibly confusing, but there is no other replace query in mysql.
You can do this with php

Code:
$replace = array("cat","dog","fish");
$with = "zombie";
$result = mysqli_query($dblink,"SELECT animal,id FROM pets");
while($row = mysqli_fetch_assoc($result)) { 
   $row['animal'] = mysqli_real_escape_string($dblink,stri_replace($replace,$with,$row['animal']));
   mysqli_query($dblink,"UPDATE pets SET animal = '".$row['animal']."' WHERE record_num = '".$row['id']."'");
}
k0nr4d is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote