I'm trying to INSERT INTO
a table, and I know 2 ways:
Adding rows as values:
INSERT INTO db_example.tab_example (id,name,surname,group)
VALUES ('','Tom','Hanks','1');
or from another table:
INSERT INTO db_example.tab_example (id,name,surname)
SELECT ID,first_name,last_name FROM db_contacts.tab_mygroup;
but what if I want to insert some values from another table (the second way), and some values manually like a default value (the first way).
here's my try (it didn't work):
INSERT INTO db_example.tab_example (id,name,surname,group)
VALUES (
SELECT ID FROM db_contacts.tab_mygroup,
SELECT first_name FROM db_contacts.tab_mygroup,
SELECT last_name FROM db_contacts.tab_mygroup,
'1'
);
I thought of creating a VIEW
table and it might solve the problem, but I thought there might be someway to add both together.
Thank you guys! I hope I described well what I need :)
SELECT
ing 4 values, for one... – Gretchengrete