sql - select @@identity 是做什么的?

标签 sql mysql excel vba odbc

我正在使用 odbc 通过 excel 连接到 mysql 数据库

这条线是做什么的?

Set rs = oConn.Execute("SELECT @@identity", , adCmdText)

我在更新数据库时遇到问题:

   With rs
        .AddNew ' create a new record
        ' add values to each field in the record
        .Fields("datapath") = dpath
        .Fields("analysistime") = atime
        .Fields("reporttime") = rtime
        .Fields("lastcalib") = lcalib
        .Fields("analystname") = aname
        .Fields("reportname") = rname
        .Fields("batchstate") = "bstate"
        .Fields("instrument") = "NA"
        .Update ' stores the new record
    End With

它只更新 .Fields("instrument") = "NA",但对于所有其他字段,它都放置 NULL 值

最佳答案

它选择(并返回)插入到当前连接中 IDENTITY COLUMN 中的最后一个值。

这里是关于这个主题的引用资料

http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html

关于sql - select @@identity 是做什么的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2822260/

相关文章:

sql - 根据 14 天的间隔创建组

mysql - Rails 3.o MYSQL 连接问题

excel - 将字符串附加到 VBA 中的粗体字符串

c++ - 在c++ xll中从excel中接收一个矩阵,修改并返回

Mysql:无法创建表 errno 150

python - 不同间隔的日期差异

mysql - 如何加密 MySQL 中的值?

mysql - 将表连接到依赖于表的 View 时,这是 Oracle 中的错误吗

mysql - 插入数据时,插入语句与外键约束冲突

excel - Go - 是否可以加密 excel 工作簿