有两个表,一个是目标信息与号码相绑定的表,一个是要插入的表
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里面插入多条记录求赐教

解决方案 »

  1.   

    while len(@user_tel)>0
    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你可以写个函数,方便一点。
      

  2.   

    试过了,发现不行~不过你启发了我~谢谢
    自己写了个insert into SMS_BOXSENDING ("SENDER","RECEIVER","CONTENT")
            select '123', user_tel ,'zzz'
            from tags_to_tel
            where tag_name='ai_fit4301'
    达到了预期的效果
      

  3.   

    insert into SMS_BOXSENDING ("SENDER","RECEIVER","CONTENT")
     select '123', user_tel,'zzz' from tels where im='123'
    --把结果集插入表中