Okay for various reasons I need to make sure an auto incremental ID is not in another table when it is inserted. So the ID in table1 cannot be the same as the ID in table2. The ID in both tables must be auto incremented but the numbers cannot be the same as ID from both are inserted into another table with a trigger. I cannot have the auto incremental value set higher on one table than the other as that causes other problems.
My idea is to have a WHERE clause with a sub query in the auto increment part of the schema but I am not sure if that’s possible.
Any ideas?
I would recommend using a trigger to check whether the next ID exists using
BEFORE INSERT.This resource will show you how to fetch the next
AUTO_INCREMENTvalue and this resource outlines how to create aBEFORE INSERTtrigger. Hopefully these resources can get you on the right path.