I would like to have a trigger to perform following operation for inserted records:
# pseudocode
if new.group_id is null
set new.group_id = new.id
els
I believe that this will work for you
I have two tables
test_b: a_id, value
test_c: a_id, value
And here is a trigger on the insert of test b. It checks to see if a_id is null and if it is it inserts 0
CREATE TRIGGER test_b AFTER INSERT ON test_b
FOR EACH ROW
INSERT INTO test_c (a_id, value) VALUES (IFNULL(NEW.a_id, 0),NEW.value)