Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Anders Altberg
  Where is Anders Altberg?
 Anders Altberg
 To: mohammed qasem
  Where is mohammed qasem?
 mohammed qasem
Subject: RE: subtract 2 fields
Thread ID: 289194 Message ID: 289239 # Views: 40 # Ratings: 0
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Wednesday, December 29, 2010 7:48:22 PM         

> hi all,
> i try as below ...wrong result ane repated values
> SELECT  ( TAlias1.f4-TAlias2.f4) as newf4,( TAlias1.f6-TAlias2.f6) as newf6 FROM mytab  TAlias1,mytab1 TAlias2 into CURSOR mycur

> thanks

You have not defined a join condition in a WHERE clause.
If you don't you will create what is called a Cartesian join where every row in Table is joined to every row in Table2: if Table1 has 100 rows and Table2 has 1000 rows you will get a result with 100000 rows.
You had better define the relation with a JOIN clause:
FROM Table1 JOIN Table2 ON Table1.keyfield = Table2.keyfield

Always define a Primary Key field. Define Foreign Key fields. Use the Query or View Designer, and they will write thye SQL code correctly for you.


subtract 2 fields Posted by mohammed qasem @ 12/29/2010 8:47:07 AM
RE: subtract 2 fields Posted by Ony Too @ 12/29/2010 9:28:58 AM
RE: subtract 2 fields Posted by Anders Altberg @ 12/29/2010 7:48:22 PM
RE: subtract 2 fields Posted by mohammed qasem @ 12/30/2010 5:39:49 PM