mysql add "prefix" to every value in column mysql add "prefix" to every value in column php php

mysql add "prefix" to every value in column


Actually it's even easier.

UPDATE table SET column_name = CONCAT('pn_', column_name)

Without a WHERE clause it will update all the rows of your table


SELECT concat('pn_', column_name) AS column_nameFROM yourtable

but why do this at the database layer? It's trivial to do it in PHP:

SELECT column_name ...while($row = mysql_fetch_assoc($result)) {   $data = 'pn_' . $row['column_name'];}


i think this is what you want

$que = "SELECT column_name FROM table";$res = mysql_query($que, $con);if(mysql_num_rows($res)>0){while($row = mysql_fetch_array($res)){  echo "PN_". $row['column_name'];}}

if you only want to show it wit pn_ at the beginnningbut if you want to change it also in the database you need to select all get the id value andupdate it with concatination