I have two SQL tables, table1 and table2.
table1 has two columns, and I want to insert values ββinto these columns. one of the columns should get a static value, and the other column should get a value that is the result of a query from table2.
If I wanted to insert static data separately, I would do:
INSERT INTO table1(login_id)
VALUES ('1234');
and if I wanted to insert the dynamic value separately, I would do:
INSERT INTO table1(user_uuid)
SELECT users_uuid FROM table2 where first_name like 'ortal';
How can I insert both values ββinto table1 in one step?
If I try the first request, I get:
11:20:45 INSERT INTO table1(login_id ,user_uuid) VALUES ('1234') Error Code: 1136. Column count doesn't match value count at row 1 0.000 sec
INSERT INTO `users`.`table1` (`login_id`) VALUES ('1234');
ERROR 1364: 1364: Field 'user_uuid' doesn't have a default value
source
share