(beginner user here)...need help (learning sql server 2000)
I have three tables, Customers (C), Orders (O), and Order_Line (OL). OL.Order_number relates to O.Order_number(pk). O.Customer_number relates to C.Customer_number(pk). The customer table has a "balance" field. I need to create a trigger to update the customer's balance when an order is placed. The update is only to run if a single row is being added to the ORDER-LINE table.
I sort of understand triggers, but so far have only done them when two tables directly linked are involved. In this case, the number ordered and price are in the OL table. These two multiplied together (to get the total) are to be added to the customers balance. So in my code, I've included the following statement:
Where I'm stumped is my WHERE statement. I'm totally clueless as to what to do?! In my other examples, there is only one WHERE clause, like this example(i is inserted)
But in this case the table that has the field I'm updating isn't directly connected to the table that will trigger. I'm confused. Can someone help me.