1

I have a MySql table with three columns:

CU VARCHAR(3)
DA DATETIME
VA DOUBLE

I need to execute several REPLACE into mytable (CU, DA, VA) values("ABC", mydate, myval) statements from Java. mydate is a Date and myval is a double.

My question is, assuming I have a connection to my database, how do I format and include mydate and myval properly in this string statement?

1

Here is the output of the NOW() function

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2012-04-24 22:07:47 |
+---------------------+
1 row in set (0.03 sec)

mysql>

This is the format to enter mydate. For a double, just append .0 to any integer. No need for numbers to to have quotes:

REPLACE into mytable (CU, DA, VA) values('ABC', '2012-04-24 22:07:47', 23.0);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.