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

前端 未结 2 935
难免孤独
难免孤独 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:25

    You should be able to use the following syntax, assuming you're on SQL server 2008:

    INSERT INTO StudentSkill (StudentID, SkillID)
    VALUES (100, 1), (100, 2), (100, 3)
    

    This method gleaned from here, which also contains a couple of alternative methods.

    You'll just need to iterate over the list of IDs in FORM.skillid (assuming that's how your form works) to build up the SQL above. Also, make sure you use on the values when you build up the SQL. Something like the code below ought to do:

    
      
       INSERT INTO StudentSkill (StudentID, SkillID)
        VALUES
       
         (, 
           )
       
      
    
    

提交回复
热议问题