Hello everyone!
I would like to start by saying thanks to everyone who takes some time to view this thread and try to help.
I have 2 tables, Table1 and Table2, and I need to insert some data into Table2, but also I have to insert value of Table1's primary key which is autonumber.
I have tried to insert Table1's primary key with this query:
INSERT INTO Table2
(
table1_pk
)
SELECT
MAX(Table1.table1_pk)
FROM Table1;
It worked.
I have tried to insert some data into Table2 with this query:
INSERT INTO Table2
(
some_column
)
VALUES
(
some_value
)
It worked.
My question is,
how can I insert into Table2 both Table1's primary key value and some data?
For example:
INSERT INTO Table2
(
table1_pk,
some_column
)
VALUES
(
SELECT
MAX(Table1.table1_pk)
FROM Table1,
some_data
);
I know the above query is incorrect; it just serves to illustrate my question.
I work in MS Visual Studio Express 2008, on Windows XP, in C++, using pure WIN32 API.
If any other information is required (source code or something similar), please ask for it; I will more than gladly supply it.