Hi guys, I'm having a really terrible problem with my mysql coding and I'ld appreciate any help I can get on this cause it's really driving me crazy.
I have two tables and I've succeeded in creating a one to many relationship between both table but the problem I'm having is that I dont know how to put the value of the foreign key into the table. The tales are as below: N.B: I'm using php-mysql //Table 1 $result= mysql_query("CREATE TABLE tbl1 (tbl1_id INT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY(tbl1_id), entrytitle VARCHAR(50), entrytext TEXT) ENGINE=InnoDB") //Table2 $result = mysql_query("CREATE TABLE tbl2 (tbl2_id INT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY(tbl2_id), tbl1_id INT UNSIGNED NOT NULL, name VARCHAR(50), title VARCHAR(50), comment TEXT, INDEX (tbl1_id), FOREIGN KEY(tbl1_id) REFERENCES tbl1(tbl1_id))ENGINE=InnoDB") Now I have successfully created a relationship between the two tables but how do I make sure the value of tbl1_id in tbl1 is equal to the value of tbl1_id in tbl2??? Thanks in anicipation of your useful suggestions. Alugo Abdulazeez. www.frangeovic.com _________________________________________________________________ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us