ColdFusion: How to insert a list with a static foreign key in one insert?

前端 未结 4 1450
北海茫月
北海茫月 2021-01-21 10:45

I have a list like this thing1,thing2,thing3. And I want to insert them into a look-up table with the same foreign key. So ideally it would look like this:



        
4条回答
  •  既然无缘
    2021-01-21 10:50

    I would add a counter and increment it inside the loop. Also you need to use listLen() rather than len on your list to get the number of items.

    
      INSERT INTO lkp_things (foreign_key, thing) VALUES
      
      
        (
         ,
         
        ),
       
      
    
    

    You should use cfqueryparam on all your values. I've guessed on what type the column is.

提交回复
热议问题