2
I have two tables users
and users_info
, would like to use foreign key, for when I create a record in the table users
, create a record with the empty fields in the table users_info
, only with the id_user
filled, it is possible?
2
I have two tables users
and users_info
, would like to use foreign key, for when I create a record in the table users
, create a record with the empty fields in the table users_info
, only with the id_user
filled, it is possible?
3
I think it would look like this, remember that the table fields user_info
shall permit null values.
CREATE TRIGGER tg_user
AFTER INSERT ON users
FOR EACH ROW
INSERT INTO user_info (id_user, outro_campo, exemplo)
SELECT NEW.id, NULL, NULL
FROM users
WHERE id = NEW.id
I’ll test and give you a feedback ;)
Browser other questions tagged mysql sql node.js
You are not signed in. Login or sign up in order to post.
to create another record, you will need a Trigger
– Rovann Linhalis
@Rovannlinhalis Could you give me an example of how you would do it?
– Rafael Augusto
I believe you already have the answer below. =]
– Rovann Linhalis