MySQL Forums
Forum List  »  Views

inserting into two or more tables at the same time
Posted by: madther chod
Date: November 05, 2005 06:01AM

Hi,

Im new at working with databases. I have problem:

table a(id not null auto_increment PK, x enum, y enum);
table b(id not null auto_increment PK, x enum, y enum);
table main(id not null auto_increment PK, a1 int default null, b1 int default null);

a1 and b1 reference a.id and b.id respectively. My problem is inserting values into tables a and b that can be accessed at one instance in main.
Eg. Table Main
id a1 b1
1 null 1
2 1 2 ****

In the first instance, I just entered values in table b. In the second instance (where I have the problem) Im trying to insert values into tables a and b. b.id is 2, a.id is 1, and they should be both enetered in the same instance of table Main.

I first used triggers but I could only insert into one table. Im trying to use views.
Im guessing the view should be based on main ... but I still end up using triggers from a and b to insert into the view leading me to the same problem. If I try using a left-join, the view will be based on a and b and I dont know how to make the changes to Main.

I could really do with some help on this one. Thanks and regards.



Edited 1 time(s). Last edit at 11/05/2005 11:30AM by madther chod.

Options: ReplyQuote


Subject
Views
Written By
Posted
inserting into two or more tables at the same time
8108
November 05, 2005 06:01AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.