什么是"错误代码: 1172 Result consisted of more than one row"?
该怎么修改?
==============================================================
CREATE PROCEDURE p1()
BEGIN
  DECLARE m_tid varchar(200);
  DECLARE m_title varchar(200);
  DECLARE m_content varchar(200);
  DECLARE hot_id varchar(200);
  DECLARE num_id int;
  DECLARE cur_title cursor for select tid,title from t_maps_hot 
          where title not in (select com_name from t_yp_thread1); 
  DECLARE continue handler for not found
  set m_content='|0|';
  open cur_title;
   loop
    fetch cur_title into m_tid,m_title;
   begin
    select count(*) into num_id from t_yp_thread1 where com_name=m_title;
    if num_id=0 then
       SET m_content=concat('|',m_tid,'|');
       insert into t_yp_thread1(maps_hot_id,com_name,im) values
        (m_content,m_title,m_title); 
    else
     begin
       select maps_hot_id into hot_id from t_yp_thread1 where    
           com_name=m_title;
       SET m_content=concat(hot_id,'|',m_tid,'|');
       insert into t_yp_thread1(maps_hot_id,com_name,im) values
              (m_content,m_title,m_title);
     end; 
    end if; 
  end;
  end loop;
  close cur_title;
END$$

解决方案 »

  1.   

    是呀 也不知道哪里错了 真急人
    不知道怎么调  我是用SQLYOG的
      

  2.   

    Where 条件语句不够充分,导致select的结果多于一条记录
      

  3.   

    为了测试我将过程修改 后 编译成功 但是在CALL P1()时 屏幕白了 没有反应  怎么回事?
    CREATE PROCEDURE p1()
    BEGIN
      DECLARE m_tid varchar(200);
      DECLARE m_title varchar(200);
      DECLARE m_content varchar(200);
      DECLARE hot_id varchar(200);
      DECLARE num_id int;
      DECLARE cur_title cursor for select tid,title from t_maps_hot where title not in   
                                  (select com_name from t_yp_thread1); 
      DECLARE continue handler for not found
      set m_content='|0|';
      open cur_title;
       loop
        fetch cur_title into m_tid,m_title;
       begin
        select count(*) into num_id from t_yp_thread1 where com_name=m_title;
        if num_id=0 then
           SET m_content=concat('|',m_tid,'|');
           insert into t_yp_thread1(maps_hot_id,com_name,im) value 
                       (m_content,m_title,m_title); 
        end if; 
       end;
      end loop;
      close cur_title;
    END$$