I’ve got this problem.. it’s soon not problem, but i want not to use more than one query if it is possible.
i want to insert data in the table using data from another table. here’s example:
i have table1:
TABLE1
id name value max_data diff
AND Here’s is table2
TABLE2
id name max_data
1 nm1 8000
2 nm2 9000
3 nm3 9500
4 nm4 9600
...
While inserting i know id from table2 and i want to use name and max_data from it. Something like this:
INSERT INTO table1 (value, diff, name, max_data) VALUES (5.0, -0.3, table2.name table2.max_data) WHERE table2.id = 3
Do you mean this?
You can include whatever literals you want in a SELECT clause. You can also use this technique to insert multiple rows at once.