>I need to combine some tables in SQL query and I also need to get the first table's records numbers.
>
>I try to build SQL query like this:
>
>Select RecNo() as RecNo_, tbl1.fld1, tbl2.fld1 from tbl1, tbl2 where tbl1.keyfield1 = tbl2.keyfield1
>
>and it works fine, but when I try to run query on three tables like this:
>
>Select RecNo() as RecNo_, tbl1.
, tbl2., tbl3. from tbl1, tbl2, tbl3 where tbl1.keyfield1 = tbl2.keyfield1 and tbl2.keyfield2 = tbl3.keyfield1
>
>then RecNo() returns the wrong values for the first table record numbers.
>
>What does it mean ? Or if I do anything wrong ?
Eugene,
Never try to use recno() in joined queries. Instead if you really need it first run a single SQL then join its results. ie:Select RecNo() as RecNo_, * from tbl1 into cursor crsTbl1 nofilter
Select a.RecNo_, a.<fld>, b.<fld>, c.<fld> ;
from crsTbl1 a ;
inner join tbl2 b on a.keyfield1 = b.keyfield1 ;
inner join tbl3 c on b.keyfield2 = c.keyfield1
Cetin