assuming that i have two tables, names
and phones
and i want to insert data from some input to the tables, in one query- How can it be done?
Please, if it can be done, explain the syntax.
assuming that i have two tables, names
and phones
and i want to insert data from some input to the tables, in one query- How can it be done?
Please, if it can be done, explain the syntax.
MySQL doesn't support multi-table insertion in a single INSERT statement. Oracle is the only one I'm aware of that does, oddly...
INSERT INTO NAMES VALUES(...)
INSERT INTO PHONES VALUES(...)
You can't. However, you CAN use a transaction and have both of them be contained within one transaction.
BEGIN TRANSACTION;
insert into table_one values ('1','2','3');
insert into table_two values ('bob','smith');
COMMIT;