I have 3 tables in Access 2007, one which a list of turbopumps and has a primary key [Numéro interne]. I'm trying to make a query that joins that table with the most recent operation of each type regarding a pump listed in the other two tables.
The recordset resulting from joining 2 tables is still updateable:
SELECT t.*, n.[Numéro attribué]
FROM Turbopompes AS t
INNER JOIN (
SELECT Turbopompe, [Date attribution], [Numéro attribué]
FROM [Turbopompes Numéros]
ORDER BY [Date attribution] DESC
) AS n ON t.[Numéro interne] = n.Turbopompe;
But no matter how I try to articulate it, joining 3 tables makes the result read-only:
SELECT t.*, n.[Numéro attribué], m.[Date maintenance], m.Détails
FROM (
Turbopompes AS t
INNER JOIN (
SELECT Turbopompe, [Date attribution], [Numéro attribué]
FROM [Turbopompes Numéros]
ORDER BY [Date attribution] DESC
) AS n ON t.[Numéro interne] = n.Turbopompe
) INNER JOIN (
SELECT Turbopompe, [Date maintenance], Détails
FROM [Turbopompes Maintenances]
ORDER BY [Date maintenance] DESC
) AS m ON t.[Numéro interne] = m.Turbopompe;
Another query I've tried with the same result:
SELECT t.*, n.[Numéro attribué], m.[Date maintenance], m.Détails
FROM (
Turbopompes AS t
INNER JOIN (
SELECT Turbopompe, [Date attribution], [Numéro attribué]
FROM [Turbopompes Numéros]
ORDER BY [Date attribution] DESC
) AS n ON t.[Numéro interne] = n.Turbopompe
) INNER JOIN (
Turbopompes AS t2
INNER JOIN (
SELECT Turbopompe, [Date maintenance], Détails
FROM [Turbopompes Maintenances]
ORDER BY [Date maintenance] DESC
) AS m ON t2.[Numéro interne] = m.Turbopompe
) ON t.[Numéro interne] = t2.[Numéro interne];
From:
http://www.fmsinc.com/Microsoftaccess/query/non-updateable/index.html
There are many reasons why your data may not be updateable. :
- Queries with multi-table joins that aren't on key fields
So the inner join between the Turbopompes and [Turbopompes Numéros] doesn't preserve the primary key? Is there any way around that?