Conditional multi table insert
... if it doesn't exist ...

See
INSERT IGNORE ...

And
INSERT INTO .. ON DUPLICATE KEY UPDATE ...

Both require a suitable UNIQUE key to catch its &quot;existence&quot;.