#更换coach_client和coach 表中手机号,如果新手机号已经注册微信号,则删掉此条在表中coach_client的记录
#例如:新手机号13691281372,旧手机号17611250001
#————————————————————— 查询数据 —————————————————
#查询coaches表数据
select
from kpl_dev.coaches
where mobile in (13691281372,13120308104);
#查询coachclients表数据
_select
_from kpl_dev.coach_clients
where mobile in (13691281372,13120308104);
_#————————————————————— 更新操作 —————————————————-
#更新coach表手机号
_update kpl_dev.coaches
set mobile=’13691281372’
where mobile=’13120308104’ limit 1;
#判断coach_clients中是否存在新手机号的记录,存在即删除
_if exists(
#新手机号
select *
from kpl_dev.coach_clients
where mobile=’13691281372’
)
#新手机号
_delete
from kpl_dev.coach_clients
where mobile=’13691281372’ limit 1
_#更新coach_clients微信号
_update kpl_dev.coach_clients
set mobile=’13691281372’
where mobile=’13120308104’ limit 1 ;
上述SQL运行出错:
[42000][1064] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘if exists( #新手机号 select * from kpl_dev.coach_clients where m’ at line 2