1
select `usr`.`Name` AS `UserName`,`usec`.`UserID` AS `UserID`,(select `labtech`.`properties`.`Value` from `labtech`.`properties` where (`labtech`.`properties`.`Name` = 'ReportCompanyName') limit 1) AS `ReportCompanyName`,`clt`.`ClientID` AS `ClientID`,`clt`.`Name` AS `ClientName`,`clt`.`Company` AS `ClientCompanyName`,`clt`.`Phone` AS `ClientPhone`,`clt`.`Fax` AS `ClientFax`,concat(`clt`.`Address1`,if((`clt`.`Address2` is not null),concat(', ',`clt`.`Address2`),'')) AS `ClientAddress`,concat(`clt`.`City`,', ',`clt`.`State`) AS `ClientLocation`,`clt`.`Zip` AS `ClientZip`,`clt`.`Country` AS `ClientCountry` from ((`labtech`.`clients` `clt` join `labtech`.`usersec` `usec` on((`clt`.`ClientID` = `usec`.`ClientID`))) join `labtech`.`users` `usr` on(((`usec`.`UserID` = `usr`.`UserID`) and (`usr`.`Name` = convert(`f_username`() using utf8))))) group by `clt`.`ClientID`