Question 1: $query = "INSERT INTO table_no1 VALUES( NULL, $val)"; mysql_query($query) or die("Error: ".mysql_error());
$query = "INSERT INTO table_no2 VALUES( LAST_INSERT_ID(),NULL,$another_val)"; mysql_query($query) or die("Error: ".mysql_error()); Question 2: You MUST enforce referential integrity until MYSQL 4.x intorduces functioning FOREIGN keys -----Original Message----- From: Venugopal Allavatam [mailto:[EMAIL PROTECTED]] Sent: Tuesday, November 13, 2001 6:03 PM To: [EMAIL PROTECTED] Subject: Link between tables. Hello All, I need your help with the following: I have two tables: create table_no1 ( key_no1 int unsigned auto_increment not null, field_no1 int unsigned not null ); create table_no2 ( key_no1 int unsigned not null, key_no2 int unsigned primary key auto_increment not null, field_no2 int unsigned not null ); According to the information that I am going to store in the database I must have a one-to-many relationship between the table_no1 and table_no2 and the linking key is the key_no1. How do i create this link? Also, I must not be able to add records in table_no2 without the corresponding key_no1 present in table_no1. OR I need to enforce referential integrity. All suggestions are welcome. regards venu ===== ============================================================ Venugopal Allavatam Ph: (res.): 949-361-6604 1100 Calle Del Cerro, (mobile): 949-842-1767 Apt.# 123-J, San Clemente, CA-92672 E-mail: [EMAIL PROTECTED] [EMAIL PROTECTED] ============================================================ __________________________________________________ Do You Yahoo!? Find the one for you at Yahoo! Personals http://personals.yahoo.com --------------------------------------------------------------------- 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 --------------------------------------------------------------------- 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