开发者

MS Access Joins to create a new field

I have three tables in Microsoft Access.

I have a query that joins the first two on an attribute, but need to use the third table to create a "Flag" field if the MeasurementType for a given Name in Table2 is "Allowed".

Eg.

Measures            Names                     AllowedTypes
-------             -------                   -------
UniqueVa开发者_开发百科l ------->  UniqueVal (PK)  /------>  Name
Measurement         Name -----------    --->  AllowedType
MeasurementType -----------------------/      ID (PK)                    

My "Merge" query says

SELECT Measures.UniqueVal, Measures.Measurement, Measures.MeasurementType, Names,Name
FROM Measures JOIN Names on Measures.UniqueVal = Names.UniqueVal

But I need to add a "Flag Field" if the MeasurementType for that Name isn't in the AllowedTypes (There may be more than one allowed type per name). I tried doing a join like the one depicted above but I get "Join not allowed" and other such nonsense. I just can't think my way out of this cardboard box. Ideas?


Access' database engine requires you tell it explicitly what type of JOIN you want: INNER JOIN; LEFT JOIN; RIGHT JOIN.

You also had a misplaced comma in your field list.

My guess is this query is closer to what you want:

SELECT Measures.UniqueVal, Measures.Measurement, Measures.MeasurementType, Names.[Name]
FROM Measures INNER JOIN Names on Measures.UniqueVal = Names.UniqueVal
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜