我开发了一个考勤管理系统,我想通过运行以下查询生成报告,它将是大量的行,我在共享主机上并且得到以下错误:
查询:
SELECT
`attendance`.*, `users`.`id` AS user_id,
CONCAT_WS(" ", `user_profiles`.`fname`, `user_profiles`.`lname` ) AS name,
`user_department`.`did`, `user_department`.`dep_name` FROM (`attendance`)
LEFT JOIN `users` ON `users`.`username` = `attendance`.`emp_code`
LEFT JOIN `user_profiles` ON `user_profiles`.`user_id` = `users`.`id`
LEFT JOIN `in_department` ON `in_department`.`user_id` = `user_profiles`.`user_id`
LEFT JOIN `user_department` ON `in_department`.`dep_id` = `user_department`.`did`
WHERE `banned` = '0'
AND `for_date` >= '2012-05-28'
AND `for_date` <= '2012-06-28'
ORDER BY `emp_code` asc, `for_date` asc
错误:
SELECT将检查超过MAX_JOIN_SIZE行;检查你的WHERE并使用SET SQL_BIG_SELECTS = 1或SET MAX_JOIN_SIZE =#如果SELECT没问题
如何使用codeigniter中的活动记录运行此查询 SET SQL_BIG_SELECTS = 1
请帮助,我需要索引我的表
答案 0 :(得分:3)
您只需发出包含SET
命令的查询:
$this->db->query('SET SQL_BIG_SELECTS=1');