Home > database >  Mysql cycle operation
Mysql cycle operation

Time:11-23

One of my column data type is varchar (05/03/2016 11:40:00 PM), want to convert the date type 23:40:00 (2016-05-03)
The code is as follows, why did not achieve the
The table name: cm2016
The original time column name: Date
New time column names: daten
 BEGIN 
Declare the done int.
Declare cur_test CURSOR for
The SELECT STR_TO_DATE ((SELECT Date FROM cm2016 LIMIT 1), '% % % % m/d/Y h: I: % % s % p')

DECLARE the CONTINUE HANDLER FOR the NOT FOUND SET done=1;

The open cur_test;

PosLoop: LOOP

IF done=1 THEN
LEAVE posLoop;
END the IF;
Insert INTO cm2016 (daten) (SELECT STR_TO_DATE ((SELECT Date FROM cm2016), '% % % % m/d/Y h: I: % % s % p'));
END LOOP posLoop;
The CLOSE cur_test;
END

CodePudding user response:

Where no, what's wrong,

CodePudding user response:

reference 1st floor selling fruit net reply:
where no, what's wrong,



The BEGIN
Declare the done int
1064 - You have an error in your SQL syntax; Check the manual that corresponds to your MySQL server version for the right syntax to use near 'declare the done int' at line 2
Time: 0 s


The error


I ask, how can finish the bulk data type conversion

CodePudding user response:

MySQL does not support anonymous block, you want to save these statements in a stored procedure,

CodePudding user response:

The
reference 3 floor selling fruit net reply:
MySQL does not support anonymous block, you want to save these statements in a stored procedure,

That can bother bosses writing code, let me learning how to learn

CodePudding user response:

Mysql can't achieve the,,,

CodePudding user response:

reference 5 floor tititala reply:
mysql to achieve this,,,

The bosses have a solution

CodePudding user response:

Change the time transformation output data, type guide again after go back

CodePudding user response:

Write a function not directly
  • Related