Subject | Re: [firebird-support] How to mimic an UPDATE with a JOIN |
---|---|
Author | Lucas Franzen |
Post date | 2005-07-06T22:44:38Z |
Robert,
robert_difalco schrieb:
Given I got your sql right try sth. like:
UPDATE Versions SET
Versions.DATA=-1,
Versions.ATTRIBS=-1
WHERE EXISTS
( SELECT * FROM Elems
WHERE Versions.ELEM_ID=Elems.ID AND
Versions.ID <> Elems.GOLDEN_ID AND
Versions.NUM <= Elems.LAST_VER_NUM - 3
);
Luc.
robert_difalco schrieb:
> I would like to do something like this:I don't think you can do this in neither in FB5.x nor SQL-22 ;-)
>
> UPDATE Versions SET
> Versions.DATA=-1,
> Versions.ATTRIBS=-1
> FROM Versions JOIN Elems ON Versions.ELEM_ID=Elems.ID
> WHERE (Versions.ID <> Elems.GOLDEN_ID
> AND (Versions.NUM <= (Elems.LAST_VER_NUM - 3))));
>
> Unfortunately, at least in 1.0.3 I don't think I can do JOINS in an
> UPDATE statment.
Given I got your sql right try sth. like:
UPDATE Versions SET
Versions.DATA=-1,
Versions.ATTRIBS=-1
WHERE EXISTS
( SELECT * FROM Elems
WHERE Versions.ELEM_ID=Elems.ID AND
Versions.ID <> Elems.GOLDEN_ID AND
Versions.NUM <= Elems.LAST_VER_NUM - 3
);
Luc.