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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -