drasebt1835 2010-12-03 08:02
浏览 31
已采纳

mysql查询,怎么去呢?

I am storing data in a mysql database with unix time()

I want to select data out for days, and echo it out like this:

Monday - value
Tuesday - value
Wednesday - value
Thursday - value
Friday - value
Saturday - value
Sunday - value

value is saved in the database as value the times are saved in the database as time

So basically I want to select time from the database in a query that groups all of them as a day, Monday.. do you get what I mean?

Any help with this would be greatly appreciated.

  • 写回答

3条回答 默认 最新

  • drcigvoy48900 2010-12-03 08:05
    关注

    First, replace that integer with a real DATETIME column, then use MySQL's built-in functions to easily GROUP BY the DAYOFWEEK(column)

    http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html

    There is no advantage to storing an integer instead of a real date. Not only can you easily convert to a UNIX timestamp if you need that in your application, but you'd save storage space too.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了