mysql INSERT into multiple tables with one statement
Is it possible to insert data into 开发者_高级运维multiple tables in one statement?
For example, I have two tables (live_products and products) they are the same, except live_products is highly transactional and I keep the record count low (delete once done), where as products holds all historical data, used for reports, etc.
Currently, I'm doing two queries, but it would be nice to do something like
INSERT INTO live_products,products (id, name) values ('','')
This doesn't work... but is there something else?
Thanks!
It's not possible with a single SQL statement. But why not just write a stored procedure to do it? Then you have the ability to just call the stored procedure with a single statement, which is just as good (actually it's even better, since you can re-use the stored procedure for other things).
精彩评论