How can I update 2nd table is 1st table is updated in MySQL?
I am having two tables. For example one is Login and the other is calculation. In the login table I am having fields username and password. In calculation I am having username and fla开发者_如何学Pythong.
Now when any user is added in the login table I want make entry for that user in calculation table also.
How can I proceed for this?
Why not have the flag in the Login table?
In MySQL you should be able to set a 'trigger' on the insert operation on the login table, that can do the second insert for you. See:
http://dev.mysql.com/doc/refman/5.0/en/triggers.html
You might want to handle deletes and/or updates (change of username?) in the same way.
Meder's answer above will certainly work but prehaps the strategy you are looking for involves triggers; this will allow you to automatically update other info when ever row on a specific table is inserted, updated or deleted.
You only have to create trigger once and then any insert from any source to your LOGIN tbale will also update your CALCULATE table.
My SQL Documentation details the statement here.
精彩评论