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

Mahesh ChandRank #1 · 393.4K reputationPosted Mar 31, 2009, 6:44 PM EDT
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.
sairam73 reputationPosted Mar 31, 2009, 6:47 PM EDT
Star2 reputationPosted Apr 15, 2009, 10:55 AM EDT
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');