SELECT distinct `u`.* ,
                    `at`.`Title` AS `AcademicTitleName` ,
                    `c`.`Name` AS `AddressCountryName` ,
                    `i`.`AddressStreet` AS 'Instructor_AddressStreet' ,
                    `i`.`AddressPostcode` AS 'Instructor_AddressPostcode' ,
                    `i`.`AddressCity`  AS 'Instructor_AddressCity',
                    `i`.`AddressCountry` AS 'Instructor_AddressCountry' ,
                    `i`.`Mail` AS 'Instructor_Mail' ,
                    `i`.`Homepage` AS 'Instructor_Homepage' ,
                    `i`.`Phone` AS 'Instructor_Phone',
                    `i`.`Name` AS 'Instructor_Name',
                    (SELECT MAX(`l`.`Rank`)
                            FROM `User_tcsinternationalcom_Training_Instructor`
                            AS `t`
                            LEFT JOIN `Combat_Levels` AS `l` ON `t`.`Level` = `l`.`Id` WHERE `t`.`UserId` =  `u`.`Id` ) AS `maxrank`
                FROM `User_tcsinternationalcom` AS `u` JOIN `Countries` AS `c` ON `u`.`AddressCountry` = `c`.`Code`
    			JOIN `Instructors_DE` AS `i` ON `u`.`Id` = `i`.`UserId`
    			JOIN `AcademicTitles_DE` AS `at` ON `u`.`AcademicTitle` = `at`.`Id`
                LEFT JOIN Payments on Payments.UserId = u.Id
    			WHERE 1=1
    			
                
                AND Payments.DateTime > NOW()
                AND Payments.Type = 'multiplier'
                AND (
                    `u`.`Instruktor` != 'true' or
                    u.id not in (
                        SELECT Payments.UserId FROM Payments
                        WHERE Payments.Type = 'instructor'
                        AND Payments.DateTime > NOW() )
                    )
                
    			ORDER BY `AddressCountry` ASC , `SortOrder` ASC, `maxrank` DESC, `LastName` ASC
    			LIMIT 0,999
Error: MySQL server has gone away, last logged Query was: /home/.sites/107/site7365458/web/class/Database/User_Queries.php:95