How to use triggers in Mysql to ensure that the id of tables An and B are not duplicated

< H2 > use triggers to ensure that tables An and B id do not repeat < / H2 >

my idea is to set up C table and use triggers to create C table data and get its id to be used as the id of A table before the A table data is inserted. (table B is the same, considering the future expansion, using the base even number is not ideal.) I have
ideas, but I still can"t write them after flipping through Google. I don"t know if there is any boss who can give me a sentence template for my reference.
if it really doesn"t work, maybe I will choose to implement it at the code layer, but the performance must not be as high as that of the trigger

.
Mar.26,2021

you can understand the usage of trigger, but my personal suggestion is not to use triggers, but to implement them logically in code, so that they will be more efficient and will not put some pressure on the MySQL server. If the traffic is particularly heavy, then

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b41511-2b2c7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b41511-2b2c7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?