How to maintain unique sequence across table columns? I hava two tables registed_products and unregisted_products. Both have autoincrement primary key which can be overlapping which if 100 id exist reg table,
it can exist in unreg table as well. Insert can come from many places with in the application

There is third service expecting unique id for both type of products. 

In oracle , I could have introduced one more column in each table. Create a sequence. Now could create the trigger before_insert on both the tables so that
whenever there is an insert in any table, trigerr will get the next_val from sequence and insert in to new column. This way I can ensure unique
number across table columns.

I am not sure how to achieve the same in mysql as there are triggers but not sequences that can be used across tables ?
Plan A:  Have a 3rd table that contains an AUTO_INCREMENT plus any common columns between the two existing tables.

Plan B:  Build a "sequence" table which has 2 columns:  an AUTO_INCREMENT and another column to key into the table.  Probably REPLACE is the command to get a new id without growing the table.

REPLACE is performed in 2 steps:


DELETE any row(s) that have match on any UNIQUE key.
INSERT a new row.


Here's the table and its initialization:

    CREATE TABLE sequence (
        seq INT UNSIGNED AUTO_INCREMENT NOT NULL,
        code CHAR(1) CHARACTER SET ascii NOT NULL,
        PRIMARY KEY(seq),
        UNIQUE(code) ) ENGINE = InnoDB;
    INSERT INTO sequence (seq, code) VALUES (1, 'a');


To get the new 'next' sequence number, either use REPLACE:

    REPLACE INTO sequence (code) VALUES ('a');
    SELECT seq FROM sequence WHERE code = 'a';


Or, and this is probably faster,

    INSERT INTO sequence (seq, code)
        VALUES (NULL, 'a')
        ON DUPLICATE KEY UPDATE
            seq = LAST_INSERT_ID(seq + 1);
    SELECT LAST_INSERT_ID();