sql - How to add 'Hosts' as a seperate row despite information being displayed on same table as users -
in our db structure, have users. within table stated whether user host or not. through field 'ishost' (boolean). want run query shows users not hosts in 1 row (visitors) , row states name of host visit.
i'll copy in select , parts of query out.
select [user].firstname + [user].lastname 'visitors name', user.firstname + user.lastname 'host name', company.name 'company name', vut.autocheckouttime, vud.expectedtime 'expected time on site' [user] inner join visituser on [user].userid = visituser.userid inner join visit on visituser.visitid = visit.visitid inner join visitusertype vut on [user].defaultvisitusertypeid = vut.visitusertypeid , visituser.visitusertypeid = vut.visitusertypeid inner join visituserdate vud on visituser.visituserid = vud.visituserid left outer join company on [user].companyid = company.companyid
s'okay, remembered how this. added
hostuser.firstname + ' ' + hostuser.lastname [main host],
select and
visituser hostvisituser on visit.visitid = hostvisituser.visitid , hostvisituser.ismainhost = 1 left join [user] hostuser on hostvisituser.userid = hostuser.userid
to from. cheers if viewed anyway
Comments
Post a Comment