| google.com@pederick.com 2006-02-19, 8:37 pm |
| Hi all,
I'm stuck on how to compose a particular query. I need to return a
particular single column that varies depending on the parent SELECT's
result.
The tables are:
Quarries
------------------
QuarryId | Melway
------------------
2 | 101 H02
Distances
--------------------------------------------------
QuarryId | Map | A01 | A02 | A03 | ... | K11 | K12
--------------------------------------------------
2 | 101 | 15 | 15 | 16 | ... | 24 | 24
So I'm select the appropriate field from the Distances table based on
the Melway specified in the Quarry table:
SELECT Quarries.Melway,
(
SELECT SUBSTR(Quarries.Melway,5,3)
FROM Distances
WHERE (QuarryId=Quarries.QuarryId)
AND (Map=SUBSTR(Quarries
.Melway,1,3))
)
FROM Quarries;
Of course this just returns the grid reference (H02) - how do I tell it
that I want the column name of 'x' rather than the literal string?
Thanks in advance for any help. :)
Scott
|