怎么发到这里了呢?mysql里没有人离我。
需求:insert的一个字段是select结果集里的值。我想用游标实现了。
先谢过了

解决方案 »

  1.   

    declare
      cursor aa is
        SELECT item FROM item_template WHERE name LIKE '%无形%' LIMIT 0, 1000;
    begin
      for aaa in aa loop
        INSERT INTO creature_loot_template
          (entry,
           item,
           ChanceOrQuestChance,
           lootmode,
           groupid,
           mincountOrRef,
           maxcount,
           lootcondition,
           condition_value1,
           condition_value2)
        VALUES
          ('15550',aaa.item , '1', '1', '0', '1', '1', '0', '0', '0');
      end loop;
    end;我是这么想的。谁能帮我转换成mysql的啊?我非常非常的菜。
      

  2.   

    用了游标貌似麻烦了
    insert into creature_loot_template (entry,
           item,
           ChanceOrQuestChance,
           lootmode,
           groupid,
           mincountOrRef,
           maxcount,
           lootcondition,
           condition_value1,
           condition_value2)
    select '15550',item , '1', '1', '0', '1', '1', '0', '0', '0' FROM item_template WHERE name LIKE '%无形%' LIMIT 0, 1000;
      

  3.   

    MYSQL怎么没人理啊 关键是提问的方式,如果你直接说需求远比你给个半调子的代码更容易让别人理解你的需求。问题说明越详细,回答也会越准确!参见如何提问。(提问的智慧
      

  4.   

    我觉得我上面说的听明白的了。非得要这句话么“引用我一朋友,我看见他还在手工的一句一句的insert,我说oracle可以用游标实现,mysql估计也差不多。但是这个语法上面还是有一些差别的”