我今天如何选择所有登录用户?我有两张表,一张保存用户信息,另一张保存所有登录/注销时间信息。
table users
===================================
userid | Name | FamilyName | Position
table movements
===================================
userid | Date | Hour | Status
Table movements fields:
userid - holds user unique ID number (same as table users);
Date - holds users login/logout date (example: 2013-10-08 00:00:00);
Hour - holds users login/logout date time (example: 2013-10-08: 17:10:39);
Status - holds users flag (0 or 1) where 1 - login and 0 - logout;
表用户是不言自明的。
到目前为止,我一直在尝试这样的事情:
select p.userid,
p.Name,
p.FamilyName,
p.Position,
m.Date,
m.Status,
m.Hour
from users as p
INNER JOIN movements as m ON p.userid=m.userid;
任何帮助表示赞赏。谢谢。