我试过这样做:
$result = odbc_exec($connection, 'SELECT id FROM MyTable WHERE id = @@Identity');但它给了我
语法错误:意外的T_VARIABLE
编辑:感谢您的帮助,这里有完整的逻辑:
$result = odbc_exec($connection, 'INSERT data into the table;SELECT SCOPE_IDENTITY() AS id;');
$row = odbc_fetch_array($result); //this line gives the error!
$id = $row['id']; edit2:我错过了";“=_=
无论如何,scope_identity不起作用:
此索引中没有可用的元组。
关于取查呼叫
发布于 2012-09-26 13:33:18
插入一行后,可以使用scope_identity()查找最后插入的id。没有必要在原始表格中查找:
SELECT SCOPE_IDENTIY()如果该行被插入到另一个连接上,则可以查询id的最大值。
SELECT max(id) FROM MyTablehttps://stackoverflow.com/questions/12602945
复制相似问题