Web lists-archives.com

Re: Changing a field's data in every record




On Sat, 18 Feb 2017, debt wrote:

	How does one "grab" the existing data and then change it? Can this
	be done solely in MySQL

I am not sure to understand your question ... you usually manipulate data inside mysql ... but here it seems to me you are not talking of changing the data VALUE (UPDATE table SET column=new value WHERE ...) but of changing the DATA TYPE (ALTER TABLE table CHANGE or ALTER TABLE table MODIFY depending on whether ypou change the column name too) or even of (just) changing the FORMAT in which a value is displayed ...

	Is there a formula to change the format of the data in a single
	field in every record of a table?  She has a "timestamp??? in a
	text field formatted as 2017|02|16|04|58|42 and she wants to
	convert it to a more human readable format like 2017-02-16 @
	04:58:42

curious ... the default format for a time stamp is very similar to the latter (except for you funny at-sign) :

mysql> select time from north33 limit 1;
+---------------------+
| time                |
+---------------------+
| 2013-01-22 12:47:47 |
+---------------------+

and only if I cast it to an integer I get the other form

mysql> select time+0 from north33 limit 1;
+----------------+
| time+0         |
+----------------+
| 20130122124747 |
+----------------+

Anyhow I advise you to read the mysql manual and in particular the function chapter and the "time and date function" subchapter. E.g. here

https://dev.mysql.com/doc/refman/5.7/en/functions.html

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql