我有此日志视图,它显示所有内容。.我对如何将数据分为两列感到有些困惑(Noob)。
我看到了这个主题, how to separate one column data into two columns ,我尝试过,但是只显示了一个值...
这是我的代码:
SELECT
logs_TBL.ul_id as ID,
CONCAT(person_TBL.p_fname, ' ', SUBSTR(person_TBL.p_mname, 1,1), '. ', person_TBL.p_lname) as FullName,
login_tbl.l_userlevel as User_Level,
person_TBL.p_contact as Contact,
logs_TBL.ul_action as Action,
max(case when logs_TBL.ul_action = "Login" then logs_TBL.ul_action end) as Login,
max(case when logs_TBL.ul_action = "Logout" then logs_TBL.ul_action end) as Logout,
logs_TBL.ul_desc as Description,
logs_TBL.ul_datetime as DATETIME,
logs_TBL.ul_ip as IP
FROM user_logs_tbl logs_TBL
INNER JOIN user_login_credentials_tbl login_TBL ON logs_TBL.l_id = login_TBL.l_id
INNER JOIN user_personal_info_tbl person_TBL ON login_TBL.l_id = person_TBL.l_id
我希望结果像这样
**From this**
--------------------
| Login | DateTime |
| Logout| DateTime |
| Login | DateTime |
| Logout| DateTime |
--------------------
**To This**
----------------------------------------
| Login | DateTime | Logout | DateTime |
| Login | DateTime | Logout | DateTime |
| Login | DateTime | Logout | DateTime |
| Login | DateTime | Logout | DateTime |
----------------------------------------