problem description: change 10001 to task.task_no
in the following statementSELECT `task`.*,(case task.task_type when 1 then (select count(*) from (select uid from ncd_user_daily_tasks_record where task_no=10001 group by uid) as temp1) else (select count(*) from (select uid from ncd_user_development_tasks_record where task_no=10001 group by uid) as temp2) end)as number,(case task.task_type when 1 then (select count(*) from (select uid from ncd_user_daily_tasks_record where task_no=10001) as temp1) else (select count(*) from (select uid from ncd_user_development_tasks_record where task_no=10001) as temp2) end)as total_number FROM `op_task` `task`
there is an error that mysql Unknown column "op_task.task_no" in" where clause" cannot find this task_no field
mysql version 5.6, find out table A, all data, when table A"s task_type=1, the same number of task_no in table B and table A"s task_no, otherwise, the same number of task_no in table C and table A"s task_no,
Table An is:
CREATE TABLE `op_task` (
id int (10) unsigned NOT NULL AUTO_INCREMENT,
task_type tinyint (2) NOT NULL COMMENT "task type). 1 = daily task | 2 = growing task",
task_icon varchar (250) NOT NULL COMMENT "task icon",
task_no int (5) unsigned NOT NULL COMMENT" task number",
task_name varchar (100) NOT NULL COMMENT "task name",
task_point int (11) unsigned NOT NULL DEFAULT"0" COMMENT "reward points",
task_receive_times int (11) DEFAULT "1percent,
task_remark)
task_show_status int (1) unsigned DEFAULT"1" COMMENT "whether to display: 1-display, 2-do not display",
task_sort int (11) NOT NULL DEFAULT"0" COMMENT "sort, sort from big to small",
task_status tinyint (1) DEFAULT"1" COMMENT "status. 1 = normal | 0 = disabled",
PRIMARY KEY ( id ),
UNIQUE KEY IDX_OP_TASK_TASK_NO ( task_no )
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 COMMENT=" daily task table"
Table B is:
CREATE TABLE `ncd_user_daily_tasks_record` (
id bigint (20) unsigned NOT NULL AUTO_INCREMENT,
uid int (11) unsigned NOT NULL,
task_no int (5) unsigned NOT NULL COMMENT "task number",
finish_time int (11) unsigned NOT NULL COMMENT "completion time",
finish_date int (8) unsigned NOT NULL COMMENT "completion time yyyymmdd",
PRIMARY KEY ( id ),
KEY < KEY > KEY
KEY IDX_NCD_USER_DAILY_TASKS_RECORD_FINISH_DATE_TASK_NO ( finish_date , task_no ) USING BTREE,
KEY IDX_NCD_USER_DAILY_TASKS_RECORD_UID_TASK_NO ( uid , task_no ) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=139 DEFAULT CHARSET=utf8 COMMENT=" Daily Task completion record"
Table C is:
CREATE TABLE `ncd_user_development_tasks_record` (
id bigint (20) unsigned NOT NULL AUTO_INCREMENT,
uid int (11) unsigned NOT NULL,
task_no int (5) unsigned NOT NULL COMMENT "task number",
finish_time int (11) unsigned NOT NULL COMMENT "completion time",
finish_date int (8) unsigned NOT NULL COMMENT "completion time yyyymmdd",
PRIMARY KEY ( id ),
KEY < KEY > KEY
KEY IDX_NCD_USER_DEV_TASKS_UID_TASK_NO ( uid , task_no ) USING BTREE,
KEY IDX_NCD_USER_DEV_TASKS_FINISH_DATE_TASK_NO ( finish_date , task_no ) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8 COMMENT=" growth task completion record"
