Hello Wallace,
It depends on what you mean by "at once". There is no way to make an
insert into multiple tables in the same statement. Each statement can
only insert into a single table. To insert into two tables, you would
need two separate statements such as:
INSERT INTO TABLE_A VALUES (...);
INSERT INTO TABLE_B VALUES (...);
Although you cannot insert into two tables in the same statement, you
can make the inserts happen at the same time. In other words, you can
make it so that either both inserts succeed, or both inserts fail. To
do this you use database transactions (
http://en.wikipedia.org/wiki/
Database_transaction).
You can start a transaction using the BEGIN statement, and end the
transaction either using COMMIT (which means save everything you did),
or ROLLBACK (which means undo everything you did). So to insert rows
into two tables "at once", you would use:
BEGIN -- Starts the transaction
INSERT INTO TABLE_A VALUES (...);
INSERT INTO TABLE_B VALUES (...);
COMMIT -- Save the transaction
Hope this helps :)
- Eric
On Aug 9, 3:06 pm, Wallace Henrique <
wallacehenrique.si...@gmail.com>
wrote: