What must i do when i wish to place related data to various tables and something the insertions fail. So merely a area of the important related information is placed to among the tables. I quickly clearly do not want that data fracture to remain in the table since it is not helpful alone. Do you know the easiest ways and method to implement this type of behavior?
Among the best things that can be done is placed the car invest in . After that you are able to nest it inside a transaction. That method for you to give a conditional when the table does not fully update, roll back which is not saved for your disk.
START TRANSACTION; SELECT @A:=SUM(salary) FROM table1 WHERE type=1; UPDATE table2 SET summary=@A WHERE type=1; COMMIT;
I acquired this in the MYSQL website: http://dev.mysql.com/doc/refman/5.0/en/commit.html
This is exactly what transactions are for.
A transaction systems a lot of transactions. In the finish a transaction is either committed (all the new changes made hit the disk) or folded back (not one of them are)
You begin a transaction using the
BEGIN statement, commit it with
COMMIT, and roll it back with