SQL insert which updates one table and based on a field value chooses what other table needs updating
What you are looking for is called Trigger.
For example:
https://sqlite.org/lang_createtrigger.html
I've wrote a little sample for sqlite, you could repeat everything on any unix/linux system.
The init.sh:
# cat init.sh 

echo &quot;CREATE TABLE 'first_table' ( id integer primary key, \
                        name            text DEFAULT 'noname', \
                        type            text DEFAULT 'blue', \
                        blabla          int  DEFAULT 0 \
                        );&quot;

echo &quot;CREATE TABLE 'blue_table' ( id integer primary key, \
                        name            text DEFAULT 'noname', \
                        blabla          int  DEFAULT 1 \
                        );&quot;

echo &quot;CREATE TABLE 'red_table' ( id integer primary key, \
                        name            text DEFAULT 'noname', \
                        blabla          int  DEFAULT 2 \
                        );&quot;

echo &quot;CREATE TRIGGER t1 AFTER INSERT ON first_table \
        FOR EACH ROW \
                WHEN NEW.type != 'blue' \
                BEGIN \
                        INSERT INTO blue_table ( name ) VALUES ( NEW.name ); \
                END;&quot;

echo &quot;CREATE TRIGGER t2 AFTER INSERT ON first_table \
        FOR EACH ROW \
                WHEN NEW.type != 'red' \
                BEGIN \
                        INSERT INTO red_table ( name ) VALUES ( NEW.name ); \
                END;&quot;

echo &quot;INSERT INTO first_table ( name, type ) VALUES ( 'ololo1', 'red' ), ( 'ololo2', 'blue' ), ( 'ololo3', 'blue' ), ( 'ololo4', 'red' );&quot;

Firstly, here, you are create 3 tables, thereafter 2 triggers, which are fires according to type field, if type is 'red' - fired 1st trigger, if type is 'blue' - another one.
Usage:
# bash init.sh | sqlite3 tmp.db
# echo &quot;SELECT * FROM red_table;&quot; | sqlite3 tmp.db 
1|ololo2|2
2|ololo3|2
# echo &quot;SELECT * FROM blue_table;&quot; | sqlite3 tmp.db 
1|ololo1|1
2|ololo4|1