
use db;

-- all users, every signup ever
select u.goo, lower(u.email) as email, u.name, u.id as userid, s.session as sessionid, s.certified_at, e.title, e.starttime, e.type, e.id as sesid, 
e.parent  from conf_users u
join conf_signups s on u.id = s.user
join conf_sessions e on e.id = s.session
order by lower(u.name), e.starttime;


-- all comments on all sessions by all users ever
select lower(u.email) as email, u.id, a.session, a.answer from conf_answers a
join conf_users u on a.user=u.id 
where a.question=2
order by lower(u.name), a.session;


-- sample INSERT
INSERT INTO `conf_sessions` (`id`, `title`, `desc`, `type`, `length`, `starttime`, `track`, `location`, `location_irl`, `mode`, `gets_survey`, `is_flex_approved`, `category`, `category_b`, `author`, `is_custom`, `parent`, `recording`, `instructions`, `benefit`, `image_url`, `cal_uid`) VALUES
(1386,	'Gav Connect Faculty Training',	'Gav Connect is a comprehensive online technology used to communicate with students about their academic progress and connect them with the campus support and guidance they need to succeed throughout their college journey. Come learn how you can use Gav Connect in your classroom to support student success with just a few clicks of a mouse!\r\n<ul><li>Let your students know you are concerned about their attendance or their grade\r\n</li><li>Give your students a “pat on the back” for a job well done\r\n</li><li>Make a quick referral to academic support services, El Centro, and/or Mental Health Counseling</li></ul>',	101,	1,	'2024-01-26 13:00:00',	2,	'',	'SS 206',	'inperson',	1,	1,	0,	NULL,	NULL,	NULL,	1364,	NULL,	NULL,	NULL,	NULL,	NULL);

-- sample update
UPDATE conf_sessions set mode='online' where mode='zoom' and id>1386;


-- all sessions ever, with hosts
select s.id as sessionid, s.title, s.starttime, s.mode, s.parent, group_concat(u1.name separator ",") as hostname from conf_sessions s
join conf_hosts h on h.session=s.id
join conf_users u1 on h.host=u1.id
group by s.id
order by s.id desc;


-- all sessions ever, with signups
select s.id as sessionid, s.title, s.starttime, u.name from conf_sessions s
join conf_signups i on i.session=s.id
join conf_users u on u.id=i.user
order by s.id desc;


-- all sessions ever, with ratings, comments
select s.id as sessionid, s.title, s.starttime, u.name, a.answer, a.question from conf_sessions s
join conf_answers a on a.session=s.id
join conf_users u on u.id=a.user
order by s.id desc, a.question;



