可能重複:
SQL: How to get the id of values I just INSERTed?等效mysql_insert_id()對MS SQL服務器的
對於PHP,什麼是爲SQL Server 2012等效mysql_insert_id()
?
sqlsrv_insert_id()
似乎並不存在。
說這是代碼
if ($result) {
// get user details
$uid = mysql_insert_id(); // last inserted id
$result = mysql_query("SELECT * FROM users WHERE uid = $uid");
// return user details
return mysql_fetch_array($result);
} else {
return false;
}
爲MySQL, 我應該怎麼做的SQL Server?
嗯..但它不提供一個PHP語法? – william007
PDO有[lastInsertId](http://www.php.net/manual/en/pdo.lastinsertid.php),切換到PDO可能是一個好主意? – fvu