Get table ID after insert with ColdFusion and MySQL

前端 未结 5 428
遥遥无期
遥遥无期 2021-01-04 02:33

My normal process for inserting into one table and then getting the ID back so that I can insert into another table is like this in MSSQL:

DECLARE @transacti         


        
5条回答
  •  没有蜡笔的小新
    2021-01-04 03:03

    The getGeneratedKey function at cflib.org can be used with most databases:

    Example:

    
        insert into artists (firstName, lastName)
        values('todd','sharp')
    
    
        select *
        from   artists
    
    
    #getGeneratedKey(r)#
    
    
    
          
          
              
          
              
          
              
          
                
          
              
          
              
          
    
    

提交回复
热议问题