有两个表,一个是目标信息与号码相绑定的表,一个是要插入的表
select @user_tel=user_tel from tels where im=‘123’假设查出来返回值是111,222
那就插入两条记录where user_tel=111和user_tel=222
就是分别插入values('123',111,'zzz')
values('123',222,'zzz')
insert into SMS_BOXSENDING ("SENDER","RECEIVER","CONTENT") values ('123',@user_tel,'zzz')
假设select的结果是多个返回值,那就往SMS_BOXSENDING里面插入多条记录求赐教
select @user_tel=user_tel from tels where im=‘123’假设查出来返回值是111,222
那就插入两条记录where user_tel=111和user_tel=222
就是分别插入values('123',111,'zzz')
values('123',222,'zzz')
insert into SMS_BOXSENDING ("SENDER","RECEIVER","CONTENT") values ('123',@user_tel,'zzz')
假设select的结果是多个返回值,那就往SMS_BOXSENDING里面插入多条记录求赐教
begin
insert into SMS_BOXSENDING ("SENDER","RECEIVER","CONTENT")
values ('123',left(@user_tel,charindex(',',@user_tel)-1),'zzz')
set @user_tel=right(@user_tel,len(@user_tel)-charindex(',',@user_tel))
end你可以写个函数,方便一点。
自己写了个insert into SMS_BOXSENDING ("SENDER","RECEIVER","CONTENT")
select '123', user_tel ,'zzz'
from tags_to_tel
where tag_name='ai_fit4301'
达到了预期的效果
select '123', user_tel,'zzz' from tels where im='123'
--把结果集插入表中