Mysql updating dates in a table

Craig White craigwhite at azapple.com
Tue Aug 4 16:26:46 MST 2009


On Tue, 2009-08-04 at 16:21 -0700, JD Austin wrote:
> http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html
> You can use Str_to_date to convert it to a date.
> Date/timestamp data should be one of the date types (Datetime, date,
> timestamp).
> I'd do it like this (all sql and won't lose data):
>      1. Add a column to the table that is date/datetime/timestamp (in
>         your case date looks right)
>      2. update the new column using the str_to_date function
>      3. Check for rows that have nulls in that column - fix them
>      4. set the existing column value to NULL
>      5. change the column to a date using alter table.
>      6. update the column to be whatever you called the new column you
>         added.
>      7. Drop the new column that you added.
>      8. add not null constraint to your original date column
----
Yes, I am on dev.mysql.com... (v5.0 is correct too)

OK, well they imported as dates...just wrong dates, completely wrong
dates.

I have done 'set' the contents of one field from another field before I
think...that was easy.

So how would I import records with the same primary key and just add a
new date field to the existing records with matching primary key?

Craig


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the PLUG-discuss mailing list