Hi Andreas!
Andreas Bauer wrote:
In my postgres database, the value of the
insert into command of the table 2 is
currval(sequence).There are severally such insert into
commands back-to-back:
insert into table1 (authorid, lastname, firstname)
values (nextval('s_authors'), 'Meyers', 'Scott');
insert into table2 (authorid, title, subtitle)
values (currval('s_authors'), 'Effektiv C++ Programmieren',
'50 Wege zur Verbesserung Ihrer Programme und Entwuerfe');
How to in mysql?
You use NULL for the first, and the LAST_INSET_ID() function for the
next table:
INSERT INTO table1 (authorid, lastname, firstname)
VALUES (NULL, 'Meyers', 'Scott');
INSERT INTO table2 (authorid, title, subtitle)
VALUES (LAST_INSERT_ID(), 'Effektiv C++ Programmieren',
'50 Wege zur Verbesserung Ihrer Programme und Entwuerfe');
You can read more about LAST_INSERT_ID() here:
http://dev.mysql.com/doc/refman/5.0/en/information-functions.html
Cheers!
--
Jay Pipes
Community Relations Manager, North America, MySQL Inc.
Roaming North America, based in Columbus, Ohio
email: [EMAIL PROTECTED] mob: +1 614 406 1267
Are You MySQL Certified? http://www.mysql.com/certification
Got Cluster? http://www.mysql.com/cluster
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]