Subject | Re: Copy records |
---|---|
Author | Svein Erling Tysvær |
Post date | 2004-08-05T11:56:35Z |
Hi Primoz!
M2 is just an alias ensuring that the two instances of 'master' are
considered separate (I don't think it is needed in this case, but I
wasn't certain so I put it in), and you could equally well write
INSERT INTO master (ID, Name, Town)
SELECT 'ID2', Primoz.Name, Primoz.Town
FROM master Primoz
WHERE Primoz.ID = 'ID1';
Firebird doesn't have any autoincrement fields, but if you mean a
field that is populated through a trigger using a generator (the
'normal' way to simulate an autoincrement field), then you would
simply leave it out of the insert statement altogether:
INSERT INTO master (Name, Town)
SELECT Primoz.Name, Primoz.Town
FROM master Primoz
WHERE Primoz.ID = 'ID1';
HTH,
Set
M2 is just an alias ensuring that the two instances of 'master' are
considered separate (I don't think it is needed in this case, but I
wasn't certain so I put it in), and you could equally well write
INSERT INTO master (ID, Name, Town)
SELECT 'ID2', Primoz.Name, Primoz.Town
FROM master Primoz
WHERE Primoz.ID = 'ID1';
Firebird doesn't have any autoincrement fields, but if you mean a
field that is populated through a trigger using a generator (the
'normal' way to simulate an autoincrement field), then you would
simply leave it out of the insert statement altogether:
INSERT INTO master (Name, Town)
SELECT Primoz.Name, Primoz.Town
FROM master Primoz
WHERE Primoz.ID = 'ID1';
HTH,
Set
>INSERT INTO master (ID, Name, Town)
>SELECT 'ID2', M2.Name, M2.Town
>FROM master M2
>WHERE M2.ID = 'ID1';
>
> Thanks for both answers.
>
> What does M2 stand for ?
>
>
> What if ID is an autoincrement field ? What should I put instead of
> 'ID2' ?
>
>
> Regards,
> Primoz