Add Custom Column Result as new Column to MYSQL DB

Viewed 23

New to MYSQL I want each rowto make a new value out of old column values and add that to my db. I can get my new date value like this:

SELECT date(created_at) as formatted_date FROM mytable;

It gives me the correct fully populated column of values but it doesnt add it to the DB.

So I want a new permanent column in my database. This will be populated by values in an existing column but edited. EG

if

id    name   price
1      shoes   10
2      cars    200

I want new row like price -50%

id   name   price  price-50%
1   Shoes    10    5
2   cars     200  100

I've tried some inserts but havent managed to get it right yet. Forgive my ignorance but I cant seem to permanently add this result to the table as a new column.

0 Answers
Related