douju6850 2016-08-25 15:05
浏览 16

MYSQL查询只显示在线Open案例

I have an MYSQL query I need to only display Open Cases the open status is in another table so I need to link History.sid to Client.ref

The table looks like Client which has fields ref and statusRB which statusRB shows Open and Closed and then History which has sid which is same id number as ref

So i need to find a way a lining sid to ref before it displays the results of only Open cases

$query = mysql_query("select FROM_UNIXTIME(a.maxepoch,\"%d-%m-%Y\"),  b.id, b.sid, b.did,  b.type, b.nextaction, FROM_UNIXTIME(b.nextactiondate,\"%d-%m-%Y\") from History b,
(select  max(epoch) as maxepoch  from History
group by did) a
#where a.maxepoch = b.epoch and b.epoch < (unix_timestamp(now()) - 2592000)
Where a.maxepoch = b.epoch and b.epoch < (unix_timestamp(now()) - 604800)
order by b.epoch desc");


  $mydate = date("d-m-Y");

  $message = "<br><br><h1>30 day Report for $mydate</h1><br>";

  $message .= "<table border=\"1\"><tr><strong><td>Customer Ref</td><td>Client Ref</td><td>Action</td><td>Action Date</td><td>Next Action</td><td>Next Action Date</td></strong></tr>";

  while ($def = mysql_fetch_row($query)) {

    $sid = $def[2];
    $did = $def[3];
    $type = $def[4];
    $nextaction = $def[5];
    $nextactiondate = $def[6];
    $maxepoch = $def[0];
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用
    • ¥15 微信小程序协议怎么写
    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害