dsy1971 2016-08-06 19:35
浏览 35

无法通过此查询获得正确的开始日期和结束日期

While adding additional functionality to my search i am not able to fetch the correct start and end Date, always gives me back the first start and date of the first person in the table for every search and they should be different. (This happens while I search with department or borad), Am I doing something wrong with my query i don't know:

$query = "SELECT * 
          FROM tblperson
            JOIN members 
          WHERE ".$persondepartment." like '%".$personboard."%' 
            AND members.personid = tblperson.personid 
          GROUP BY personname;";

And this is the results i get: Start Date and End Date should be different as in the database.

1. Results: 
Name: HTC
Surname: China
Board: Evaluation
Department: Sales
Start Date: 2016-08-25 00:00:00
End Date: 2016-08-26 00:00:00

2. Results: 
Name: Ilian
Surname: Ninka
Board: Executive
Department: Sales
Start Date: 2016-08-25 00:00:00
End Date: 2016-08-26 00:00:00
  • 写回答

1条回答 默认 最新

  • dpzbh1779 2016-08-06 19:51
    关注

    Your query looks a little odd, first the group by will have a major effect on your result and is probably not what you intended.

    Secondly the JOIN look like you have got a little confused.

    So see if this is more like what you wanted to achieve.

    $query = "SELECT * 
              FROM tblperson
                 JOIN members ON members.personid = tblperson.personid 
              WHERE $persondepartment like '%$personboard%' ";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看