SELECT SQL_CALC_FOUND_ROWS DISTINCT `premfacesall`.`id` AS `premfacesall___id`, `premfacesall`.`id` AS `premfacesall___id_raw`, `premfacesall`.`file` AS `premfacesall___file`, `premfacesall`.`file` AS `premfacesall___file_raw`, `premfacesall`.`name` AS `premfacesall___name`, `premfacesall`.`name` AS `premfacesall___name_raw`, `premfacesall`.`team` AS `premfacesall___team_raw`, `premfaces_teams`.`teams` AS `premfacesall___team`, (SELECT GROUP_CONCAT(lookup.emotions SEPARATOR '//..*..//') FROM premfacesall_repeat_emotions LEFT JOIN premfaces_emotions AS lookup ON lookup.emotions = premfacesall_repeat_emotions.emotions WHERE premfacesall_repeat_emotions.parent_id = `premfacesall`.`id`) AS premfacesall___emotions, (SELECT GROUP_CONCAT(id SEPARATOR '//..*..//') FROM premfacesall_repeat_emotions WHERE parent_id = `premfacesall`.`id`) AS `premfacesall___emotions_raw`, (SELECT GROUP_CONCAT(emotions SEPARATOR '//..*..//') FROM premfacesall_repeat_emotions WHERE premfacesall_repeat_emotions.parent_id = `premfacesall`.`id`) AS premfacesall___emotions_id, (SELECT GROUP_CONCAT(params SEPARATOR '//..*..//') FROM premfacesall_repeat_emotions WHERE parent_id = `premfacesall`.`id`) AS `premfacesall___emotions___params`, `premfacesall`.`thumbs` AS `premfacesall___thumbs`, `premfacesall`.`thumbs` AS `premfacesall___thumbs_raw`, `premfacesall`.`getfilenameonly` AS `premfacesall___getfilenameonly`, `premfacesall`.`getfilenameonly` AS `premfacesall___getfilenameonly_raw`, `premfacesall`.`getinternalid` AS `premfacesall___getinternalid`, `premfacesall`.`getinternalid` AS `premfacesall___getinternalid_raw`, `premfacesall`.`copydetails` AS `premfacesall___copydetails`, `premfacesall`.`copydetails` AS `premfacesall___copydetails_raw`, `premfacesall`.`favorites` AS `premfacesall___favorites`, `premfacesall`.`favorites` AS `premfacesall___favorites_raw`, `premfacesall`.`owner` AS `premfacesall___owner`, `premfacesall`.`owner` AS `premfacesall___owner_raw`, `premfacesall`.`user` AS `premfacesall___user`, `premfacesall`.`user` AS `premfacesall___user_raw`, CONCAT_WS(':', `premfacesall`.`id`, `premfacesall`.`name`) AS slug , `premfacesall`.`id` AS `__pk_val` FROM `premfacesall` LEFT JOIN `premfaces_teams` AS `premfaces_teams` ON `premfaces_teams`.`teams` = `premfacesall`.`team` WHERE ( ( LOWER(`premfacesall`.`name`) REGEXP LOWER('david') OR LOWER(`premfaces_teams`.`teams`) regexp LOWER('david') OR LOWER((SELECT GROUP_CONCAT(lookup.emotions SEPARATOR '//..*..//') FROM premfacesall_repeat_emotions LEFT JOIN premfaces_emotions AS lookup ON lookup.emotions = premfacesall_repeat_emotions.emotions WHERE premfacesall_repeat_emotions.parent_id = `premfacesall`.`id`)) regexp LOWER('david')) ) ORDER BY `premfacesall`.`id` DESC