Hello list, I have two tables, USER and STUDENT, where all students are users. The user table has an auto-increment key field. I want to make an operation to insert users, which should insert rows in both tables (see the tables bellow).
How can I control the auto_increment field in both tables? Do I have to insert a user, make a query to get its userId and then finally insert into the student table? Isn't there a better way of doing this?? Here are the tables: CREATE TABLE USER ( userId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, login VARCHAR(80) NOT NULL, password VARCHAR(15) NOT NULL, status CHAR(1) NOT NULL, regDate DATETIME NOT NULL, UNIQUE (login)) TYPE = InnoDB; CREATE TABLE STUDENT ( userId INTEGER UNSIGNED NOT NULL PRIMARY KEY, cardsPendingCorrection INTEGER UNSIGNED NOT NULL, cardsOK INTEGER UNSIGNED NOT NULL, cardsNotValid INTEGER UNSIGNED NOT NULL, cardsCorrected INTEGER UNSIGNED NOT NULL, cardsCommented INTEGER UNSIGNED NOT NULL, pendingExercices CHAR(1) NOT NULL, teacher INTEGER UNSIGNED NOT NULL, INDEX (teacher)); Thanks, Joao. mysql --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php