Re: MySQL to SQL7 or Access
| From: | David Elliott | Date: | Wed, 13 Dec 2000 09:17:27 +0000 |
| Subject: | Re: MySQL to SQL7 or Access | ||
| References: | 1 2 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-4432@lists.php.net to get a copy of this message | ||
Hi MokLC,
On 13 December 2000 at 12:03:41 +0800 (which was 04:03 where I live) words
of wisdom emanated from MokLC.
M> My issue is this particular fuction in MySQL, mysql_insert_id() which
M> conveniently gives us a running number ID for a newly created record.
As I don't know MySQL I am not sure what you are trying to do, but I think
that you are inserting in to a table which has an identity coulum and then
trying to find that identity if so try something like this.
Information from Transact-SQL Help
==========8<=============================================================
Returns the last-inserted identity value. Syntax
@@IDENTITY
Return Types
numeric
Remarks
After an INSERT, SELECT INTO, or bulk copy statement completes, @@IDENTITY
contains the last identity value generated by the statement. If the
statement did not affect any tables with identity columns, @@IDENTITY
returns NULL. If multiple rows are inserted, generating multiple identity
values, @@IDENTITY returns the last identity value generated. If the
statement fires one or more triggers that perform inserts that generate
identity values, calling @@IDENTITY immediately after the statement
returns the last identity value generated by the triggers. The @@IDENTITY
value does not revert to a previous setting if the INSERT or SELECT INTO
statement or bulk copy fails, or if the transaction is rolled back.
Examples
This example inserts a row into a table with an identity column and uses
@@IDENTITY to display the identity value used in the new row.
INSERT INTO jobs (job_desc,min_lvl,max_lvl)
VALUES ('Accountant',12,125)
SELECT @@IDENTITY AS 'Identity'
==========8<=============================================================
--
Regards,
David
list@elliott.uk.com
_________________________________________________________________________
| David Elliott | Software Engineer | To get my PGP key pgp@elliott.uk.com|
| I am Blue Wave of Borg. Your tagline will be assimilated. |