mysql - Getting error Subquery returns more than 1 row -
i trying write following query in mysql:-
select * eon.merged_monthly_energy_data consumption>0 , ((select timestampdiff(year, mmed.start_date, curdate()) difference merged_monthly_energy_data mmed) <1) ;
however, getting following error:-
error code: 1242. subquery returns more 1 row
i not sure why subquery returning more 1 result creating problem here:-
you can use:
select * eon.merged_monthly_energy_data consumption>0 , timestampdiff(year, start_date, curdate()) < 1
your original query not check row row entire table. can mitigate using correlated subquery there no need like:
select * eon.merged_monthly_energy_data m consumption>0 , ((select timestampdiff(year, mmed.start_date, curdate()) difference merged_monthly_energy_data mmed mmed.id = m.id) <1) ;
Comments
Post a Comment