gardan06 Posted October 13, 2006 Share Posted October 13, 2006 if you set your primary key as auto_incremented and you have a query "insert into table values('','{$var2}'...)", how can you save the newly saved primary key as a variable? Quote Link to comment Share on other sites More sharing options...
extrovertive Posted October 13, 2006 Share Posted October 13, 2006 $id = mysql_insert_id Quote Link to comment Share on other sites More sharing options...
Toolmaster Posted March 15, 2008 Share Posted March 15, 2008 I know this thread is probably old, but I need help with Auto Increment.This is the table I have created with auto_increment:CREATE TABLE appointment(appointment_id MEDIUMINT NOT NULL AUTO_INCREMENT, Primary Key (appointment_id), student_id varchar(8), INDEX (student_id), FOREIGN KEY (student_id) REFERENCES student(student_id), lecturer_name varchar(50), INDEX (lecturer_name), FOREIGN KEY (lecturer_name) REFERENCES lecturer(lecturer_name), appointment_date DATE, appointment_time TIME) TYPE=INNODB;Is the auto increment value also set as a primary key through Primary Key (appointment_id) or does it overide the primary key and its rules? Quote Link to comment Share on other sites More sharing options...
Toolmaster Posted March 15, 2008 Share Posted March 15, 2008 Anyone? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted March 15, 2008 Share Posted March 15, 2008 auto increment and primary key are compatible and often used together so you don't have to manually increment the primary key. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.