java - I want to insert employee id in address table(child table)-one to many concept -


i using java jdbc connection.

my question simple, inserted employee record in employee table ex:

insert employee (emp_id,emp_name) values(10,'hello'); 

how fetch foreign key child table(address) , insert it?

if use select max(emp_id) employee , insert id child table i'm afraid of if more 1 person try insert values in employee table , there possibilities can wrong employee id child table. there possible way insert employee id in child table.

note:i require sql query how insert employee id in child table

if insert record table contains auto_increment column, can obtain value stored column calling mysql_insert_id() function.

more details refer link

https://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html


Comments