我可以在1次调用中将更新和插入组合在不同的表(带索引)上吗?

Is it possible to insert values to one table and update another table with a single mysql call? If yes, is this faster or is it faster to use two separate calls?

For Example:

table1 - cars

id - color - brand

1 - red - audi

2 - blue - pontiac

table2 - people

id - name - last

1 - dave - ann

2 - beth - elane

tables do not relate

and lets say i would like to add another row to people while same time updating table1 cars's color

is that possible ?

Use a stored procedure... Something like...

DROP PROCEDURE IF EXISTS insert_update $$
CREATE PROCEDURE insert_update
(
  IN id INT,
  IN color VARCHAR(10),
  IN name VARCHAR(20)
)
BEGIN
    -- do insert
THEN
    -- do update
END IF;

Note: I haven't written your queries for you because you didn't supply any cogent information about your tables, per se.

In terms of semantics, I think you want perform a transaction not a single query.

If all your data is MyISAM, STOP RIGHT HERE. It is no possible.

If all you data is InnoDB, there are two paradigms to could set up:

PARADIGM #1

START TRANSACTION;
INSERT INTO people ...
INSERT INTO cars ...
COMMIT;

PARADIGM #2

Do the following within the DB Session:

SET autocommit = 0;

then do all the INSERTs you want then run

COMMIT;

If you close the DB Connection, everything will rollback. So, try to commit often.