Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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