The primary key represents a combination of three seperate elements. However we are endeavouring to query for different combinations of any two of the three elements. For example, our ID consists of Year, Industry and Price and we want ot be able to display records containing either Price and Industry across any Year or any other omcbination of the three. The rationale behind this is we want to make side by side comparisons of the combinations.
Field 1 Field 2
P1-I1-Y1 Data
P1-I1-Y2 Data
P1-I2-Y1 Data
.....
The query result we aim to achieve
Y1 Y2
P1-I1-(Y1&Y2) Data Y1 Data Y2
In the query result example above we have queried across Years when our primary key is defined as a combination of the three elements. Is this possible?
Are the length of Px, Iy and Yz fixed ?
If yes, then you may try something like this:
SELECT *
FROM yourTable A INNER JOIN yourTable B
ON Left(A.Field1, 5) = Left(B.Field1, 5)
Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.