ColdFusion & MSSQL : how to insert multiple rows with one unique id in one submission

前端 未结 2 866
难免孤独
难免孤独 2021-01-19 05:35

can anyone help me on how to submit multiple rows in one submission?

this survey form will display a set of skill that derived from table skill. the teacher will hav

2条回答
  •  面向向阳花
    2021-01-19 06:10

    Another simple approach for inserting multiple records is an INSERT .. SELECT. (It is also mentioned in the link banyr posted). Because the skill id's are stored in another table, you can use an IN clause to SELECT them. Then insert those values directly into your other table studenSkill with a simple query, no looping.

    INSERT INTO studenSkill ( studenId, skillId )
    SELECT 
           , skillId
    FROM   skill
    WHERE  skillId IN 
           (
           
           )
    



        
    

    BTW, in case that is not a typo, do not forget the # signs around the query column name ie "skillid"

      
    

提交回复
热议问题