>>>Hi, Edgar!
>>>
>>>First of all, try to avoid using the reserved words as the field names
>>>
>>>
>>>USE your_table_name IN 0 ALIAS PARENTS
>>>USE your_table_name AGAIN IN 0 ALIAS CHILDS
>>>* select all childs from top record
>>>GO TOP
>>>SELECT Tname FROM CHILDS INTO CURSOR cRelations WHERE childs.pid=parents.id
>>>BROWSE nowait
>>>
>>
>>There is no need to open table twice, you could self-join the table:
>>
>>SELECT ....;
>> FROM TableName Master;
>>JOIN TableName Child ON childs.pid=parents.id;
>>INTO CURSOR crsTest
>>
>
>Hi, Borislav!
>Yes, we can use and self-join, but your syntax must be changed
>when we want to select just one field
>otherwise you will get an error about non-unique field name.
>And question was about selection one field under specific condition,
>so I think that using one table under two different aliases
>is more simple.
>WBR,
>Juri
No problems at all when you want to select as many fields as you want, you just must put alias before them:
SELECT Master.Field1, Master.Field2, Child.*;
FROM TableName Master;
JOIN TableName Child ON childs.pid=parents.id;
WHERE Master.Field3 = something;
INTO CURSOR crsTest
SELECT Master.Field1;
FROM TableName Master;
JOIN TableName Child ON childs.pid=parents.id;
WHERE Master.Field3 = something;
INTO CURSOR crsTest
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.