duande9301 2013-01-14 21:22
浏览 338
已采纳

第一个start_time和最后一个end_time,来自7个SQL行,仅显示1个SQL结果

I'm making a timesheet submit/approve function and currently working on the pending.php page, which the manager/admin can go to pending.php and view the pending timesheets for review...

my code now is:

list($qh,$num) = dbQuery(
"SELECT start_time, end_time, uid, submitid, submitstatus, submitdate, submitapprover 
FROM $TIMES_TABLE 
WHERE submitstatus=1 
ORDER BY submitid");

right now it shows all the timesheet entries for that week: example

what I really need is just one line for each week submitted. Basically, grabbing the first start_time and the last end_time and making it together (start - end) (start_time - end_time | username | id | submitdate | submit status..etc)

Someone told me to use group_catcon or something but I'm unfamiliar with that.

From my pic I would want something like:

2012-12-30 - 2013-01-05 | admin | submitid#### | submitdate | status | approver
2013-01-06 - 2013-01-09 | admin | submitid#### | submitdate | status | approver

I'm pretty new to php/mysql so my apologies

  • 写回答

2条回答 默认 最新

  • duan47676379 2013-01-14 21:29
    关注

    You may find with all these columns it divides things up more than you want. For example of there's various approvers. To that end you may want to remove some from the query.

    select 
      concat(min(start_time), ' - ', max(end_time)), 
      uid, 
      submitid, 
      submitstatus, 
      submitdate, 
      submitapprover
    FROM 
      $TIMES_TABLE
    WHERE 
      submitstatus=1 
    GROUP BY
      uid, 
      submitid, 
      submitstatus, 
      submitdate, 
      submitapprover
    ORDER BY 
      submitid
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写