开发者

insert and select record in parent child table

开发者 https://www.devze.com 2023-02-05 01:18 出处:网络
I have two table CUSTOMER as parent and PROFILE as child with one to many relationship.I want to insert and select data fro开发者_运维百科m both table simultaneouslyhow? Since u are using jdbc , to se

I have two table CUSTOMER as parent and PROFILE as child with one to many relationship.I want to insert and select data fro开发者_运维百科m both table simultaneously how?


Since u are using jdbc , to select parent and child write a join in mysql ,for example like below:

Select cust.id,cust.name,prof.id,prof.name from Customer cust join profiler prof on cust.profid=prof.id


The INSERT statement inserts into a single table. To insert rows into two tables, you'll need to use two separate INSERT statements. Place them inside a transaction to ensure that either both are completed, or neither is completed.

You may find this useful: http://download.oracle.com/javase/tutorial/jdbc/index.html

0

精彩评论

暂无评论...
验证码 换一张
取 消