Good day

What I would like to do is to alter a mysql table with data in it then add manipulated string data to that created column i.e I first add an extra column to my table then add a reverse string coded from data that had already been inserted.

I have an email field in my database so what I would actually do is to take the email address reverse string it then insert it into the newly added mysql column.

My reverse string works perfectly its just that I can't seem to add the extra column to my table, any ideas would be highly appreciated.

Here is my code

$query1="alter table Registration add column Deep text (20)";

//here's the query that selects the email field
$sql="select email fromRegistration";


echo $my_str."<br>";


But the table isn't getting altered.

3 Years
Discussion Span
Last Post by kgizo

This can be done from just mysql - no php as such req'd

ALTER TABLE Registration ADD COLUMN Deep TEXT (20)

UPDATE Registration SET Deep = REVERSE(email_add)

There's no need to do this though as you're just repeating info to some extent.

You can retrieve the reverse string at any time with php (as you've done) or...

SELECT REVERSE(email_add) AS Deep FROM Registration

So in this case Deep is just a calculated field - it doesn't exist in the DB.


Thanks diafol it's much appreciated!!

That was pretty awesome.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.