Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with RecNo() in SQL query
Message
From
11/03/2002 03:56:18
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
11/03/2002 03:21:30
Eugene Kolmakov
Millennium Technologies
Vladivostok, Russia
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00630834
Message ID:
00630838
Views:
18
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform