尝试使用mysql在没有注销时间的情况下获取成员

时间:2011-11-02 10:08:26

标签: mysql sql

我有这样的查询......

 SELECT member_Firstname, member_Lastname,
          visit_DateTime, visit_Status, visit_Logout_DateTime
          FROM members, visits
          WHERE members.member_Id = visits.member_Id
          AND members.member_Active LIKE 'y%' AND visits.visit_Status = 'accepted'  AND visits.visit_Date = '2011-11-02' Order by visit_DateTime desc limit 100;

它给出了这样的结果......

 firstname     lastname     status        visit_Logout_DateTime        visit_datetime      
-------------  --------      -------        ---------------------    ----------------
  rob           peter       accepted                                   2011-11-02 08:09:34                          
  peter          chan           accepted                                 2011-11-02 06:09:34
  rock         sam          accepted         2011-11-02 09:08:45    
  rob           peter           accepted          2011-11-02 07:09:07     2011-11-02 08:09:34      

我希望成员status = accepted,而不是visit_Logout_DateTime

任何人都会对此有所帮助.... 非常感谢...

1 个答案:

答案 0 :(得分:1)

SELECT member_Firstname, member_Lastname,
          visit_DateTime, visit_Status, visit_Logout_DateTime
          FROM members, visits
          WHERE members.member_Id = visits.member_Id AND visits.visit_Logout_DateTime is null
          AND members.member_Active LIKE 'y%' AND visits.visit_Status = 'accepted'  AND visits.visit_Date = '2011-11-02' Order by visit_DateTime desc limit 100;

这有用吗?