T
Techno_Dex
I have a record in a table that I would like to Update from one status to
another status. The problem is the record I want to update contains the
StatusID where as I only know the StatusValue from the Status Table and the
GrpName from the Doc table. I've been racking my head to get this figured
out but have had no luck so far. Any help would be much appriciated
I have tried various reworkings but here is what I have come up with so far.
(By the way, this works in TSQL on MSSQL2000). Am I missing something about
the limitations that MSAccess JET Engine has on using SubSelects or Inner
Joins?????
UPDATE Doc D
SET D.StatusID=(SELECT ID
FROM Status
WHERE StatusValue='Retired')
WHERE D.ID=(SELECT D2.ID
FROM Doc D2
INNER JOIN Status S2
ON D2.StatusID=S2.ID
WHERE D2.GrpID='AAA' AND S2.Status='Active')
Tables
Table: Doc
ID | GrpName | StatusID | Version
------------------------------------------
1 | AAA | 2 | 1
2 | AAA | 2 | 2
3 | AAA | 1 | 3 <-- Record I want to
Update. I want the new StatusID to be 2 (Retired)
4 | BBB | 2 | 1
5 | BBB | 1 | 2
Table:Status
ID | StatusValue
another status. The problem is the record I want to update contains the
StatusID where as I only know the StatusValue from the Status Table and the
GrpName from the Doc table. I've been racking my head to get this figured
out but have had no luck so far. Any help would be much appriciated
I have tried various reworkings but here is what I have come up with so far.
(By the way, this works in TSQL on MSSQL2000). Am I missing something about
the limitations that MSAccess JET Engine has on using SubSelects or Inner
Joins?????
UPDATE Doc D
SET D.StatusID=(SELECT ID
FROM Status
WHERE StatusValue='Retired')
WHERE D.ID=(SELECT D2.ID
FROM Doc D2
INNER JOIN Status S2
ON D2.StatusID=S2.ID
WHERE D2.GrpID='AAA' AND S2.Status='Active')
Tables
Table: Doc
ID | GrpName | StatusID | Version
------------------------------------------
1 | AAA | 2 | 1
2 | AAA | 2 | 2
3 | AAA | 1 | 3 <-- Record I want to
Update. I want the new StatusID to be 2 (Retired)
4 | BBB | 2 | 1
5 | BBB | 1 | 2
Table:Status
ID | StatusValue