表: ftf
id |名称
表: Ftf_sessions
id | ftfid
表:用户
id |用户名|名字|姓氏|电子邮件
表: Ftf_signups
id | sessionid |用户ID
表: Ftf_sessions_dates
id | sessionid |时间开始| timefinish
表: Ftf_signups_status
id | signupid |的StatusCode
您好,
从上表中,我试图生成一个包含以下列的报告:
ftf.name | Ftf_sessions_dates.timestart | Ftf_sessions_dates.timefinish | User.firstname | User.lastname | User.username | User.email | Ftf_signups_status.statuscode
我编写了以下sql查询,该查询除了列ftf.Name
之外还生成报告如果有人能指出我正确的方向,我真的很感激。我无法在报告中添加列ftf.Name。 感谢。
更新了查询,现在感谢。
select distinct
ftf_signups_status.statuscode as Status,
ftf.name as 'Facetoface Name',
concat(user.firstname, ' ', user.lastname) AS Name,
user.username as Username,
user.email as Email,
DATE_FORMAT( FROM_UNIXTIME( IFNULL( IF( ftf_sessions_dates.timestart <=> 0, NULL,
ftf_sessions_dates.timestart),
ftf_sessions_dates.timestart)), '%M %d, %Y' ) AS StartDate,
DATE_FORMAT( FROM_UNIXTIME( IFNULL( IF( ftf_sessions_dates.timefinish<=> 0, NULL,
ftf_sessions_dates.timefinish),
ftf_sessions_dates.timefinish)), '%M %d, %Y' ) AS FinishDate
from ftf_signups
inner join ftf_signups_status
on ftf_signups.id = ftf_signups_status.signupid
inner join user
on ftf_signups.userid = user.id
inner join ftf_sessions_dates
on ftf_signups.sessionid = ftf_sessions_dates.sessionid
inner join ftf_sessions
on ftf_signups.sessionid = ftf_sessions.id
inner join ftf
on ftf.id = ftf_sessions.facetoface