Hi,
I have to execute an insert like this:
INSERT INTO TAB1 (F1, F2)
SELECT (?), F2_T FROM TAB2
The field F1 of TAB1 is the primary key of my table and is not
auto-increment.
In TAB2 I have more than one record.
In stad of (?) i'd like to put an expression like: SELECT MAX(F1)+1
FROM TAB1
so:
INSERT INTO TAB1 (F1, F2)
SELECT (SELECT MAX(F1)+1 FROM TAB1), F2_T FROM TAB2
Unfortunatelly this don't wotks because the value of (SELECT MAX(F1)+1
FROM TAB1) is always the same, so i have an error of duplicate PK.
Onyone has an idea ?
thanks to all...
I have to execute an insert like this:
INSERT INTO TAB1 (F1, F2)
SELECT (?), F2_T FROM TAB2
The field F1 of TAB1 is the primary key of my table and is not
auto-increment.
In TAB2 I have more than one record.
In stad of (?) i'd like to put an expression like: SELECT MAX(F1)+1
FROM TAB1
so:
INSERT INTO TAB1 (F1, F2)
SELECT (SELECT MAX(F1)+1 FROM TAB1), F2_T FROM TAB2
Unfortunatelly this don't wotks because the value of (SELECT MAX(F1)+1
FROM TAB1) is always the same, so i have an error of duplicate PK.
Onyone has an idea ?
thanks to all...
Comment