I have two tables.
table 1 fields are cricID,CricName
table2 Fields are CricID,phonetype
table 1 cricID is primary key, table 2 cricID is foreign key to table1
My question is i have to insert data in both the tables. I could insert data in table 1, but i donno how to insert in table 2 because of the foreign key value. I am new to SQL . how to get foreign key value from table 1 when i insert in table 2
StarPosted Apr 15, 2009, 2:55 PM
Load data in
insert into table1(cricID,CricName) values (1,'sairam');
commit;
insert into table2(CricID,phonetype) values (1,'land line');
insert into table2(CricID,phonetype) values (2,'mobile');
sairamPosted Mar 31, 2009, 10:47 PM
Mahesh ChandPosted Mar 31, 2009, 10:44 PM
You don't need two tables for three columns only. You are basically adding redundant data in second table. This is a bad database design.
If you want to add data to second table, you want to make sure first table has data and then only you can add row to the second table.