Timezones
---------
-AreaCode varchar
-Timezone varchar
Contacts
--------
-Phone varchar
-Timezone varchar
Everything is populated except Timezone in the Contacts table, so I want to lookup the timezone for each phone number and update the contacts. Here’s what I tried to do, but MySQL gives
Error 1242 Subquery returns more than one row
For each timezone (0,-1,-2,-3,-4,-5), I execute this update:
update contacts
set contacts.timezone = '-1'
where left(contacts.phone,3) = (Select timezones.areacode
from timezones
where timezones.timezone = '-1');
Your subquery returns more than one row. Just replace “=” with “IN” to handle this issue: