【发布时间】:2014-03-24 08:35:50
【问题描述】:
我想从包含以下字段的 user_login 表中获取数据:
user_login : id、状态、日期、user_id
在这个表中status可以是1或者2
如果状态为 1,则登录,否则退出。
我想在一行中获取登录和注销这两个详细信息,为此我尝试了以下查询:
select login.date, logout.date from
(select date from user_login where userId = 1 and status = 1 and date = now()) login,
(select date from user_login where userId = 1 and status = 2 and date = now()) logout.
当登录和注销都有数据时,我会得到数据。但我也希望只有登录有数据但没有注销。
请帮我解决这个问题。
【问题讨论】: