in pare>select * from
1. An error
ERROR 1241 (21000): Operand should contain 1 column(s)
2. The reason for the error
This statement occurs mostly because the result set of a SELECT is wrapped in (). ()
code> s>t
select
pit_key
,employee_code
,department_id
,value_date
from pit_employee_department ped
where ped.employee_code = 'GSCQ3349'
and ped.value_date < date_format(date_sub(curdate(), interval day(curdate()) - 1 day),'%Y%m%d')
and ped.pit_key not in
( select
pit_key
,value_date
from pit_employee_department ped_1
inner join
(
select
max(value_date) as max_date
from pit_employee_department ped
where ped.value_date <= date_format(date_sub( date_sub(curdate(), interval day(curdate()) - 1 day),interval 1 month),'%Y%m%d')
and employee_code = 'GSSH0039'
)ped_2
on ped_1.value_date < ped_2.max_date
and ped_1.employee_code = 'GSSH0039'
);
pit_key not in (...)
pit_key
d v>_date
pit_key not in (...)
, field inconsistency causes error.
3. Solutions
Make changes for different reasons.