开发者

insert and select record in parent child table

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜