SELECT userid, username, substr(username FROM locate(' ', username) + 1) as lastname FROM user WHERE usergroupid IN (6,9) ORDER BY lastname ASC