开发者

MySQL: Arithmetic Operator Multiplication

I am trying to calculate from a field within the table. I am trying t开发者_JAVA百科o do some date range stuff. Currently I have a table with the a field named interval which stores minutes. I would like to convert this field to seconds. I know I can probably store the data as seconds but out of curiosity how come this is not working for me?

SELECT table.`interval`*60 AS interval_seconds FROM table;

If the fields contained 60 I was expecting 3600 to output. But instead I get 60. If I change the value to 5 instead of 300 I get 360. Any idea what I might be doing wrong?


Glad you found that. I used to pepper my tables with enum's, a long time ago. But issues similar to what you just faced brought me to dislike them very much. For a little more details on the dirty aspects of enums, see this post.

Happy coding!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜