>>>VFP won't let you do this
>>>
>>>
>>>SELECT table1.pk1,
>>> (select top 1 somecharfield from table2 where pk1=table1.pk1 order by pk2) as somecharfield
>>> from table1
>>>
>>>
>>>You get error message: Queries of this type are not supported
>>>
>>>
>>>Of course I can cheat with a prequery, but what's your best work around for this VFP limitation?
>>
>>It's not clear to me what you're trying to do. Your subquery is not in a WHERE clause? Can you show us the whole statement?
>
>I need the first record in table2 which is the many side of a 1 to many relationship with table1.
>
>
>SELECT table1.pk1,
> (select top 1 table2.somecharfield from table2 where table2.pk1=table1.pk1 order by table2.pk2) as somecharfield
> from table1
>
Try using
select Table1.Pk1, (select min(Table2.SomeCharField) from Table2 where Table2.Pk1 = Table1.Pk1) as SomeCharField
from Table1
If it's not broken, fix it until it is.
My Blog