Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Comparing two SQL cursors
Message
From
10/07/1999 08:00:19
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00239523
Message ID:
00239788
Views:
13
>I have pulled data from two separate SQL tables, and I need to find which rows are different. They have exactly the same structure.
>
>I have the two views which I will call cFirstSQL and cSecondSQL and I did the following thinking that this would work;
>
>SELECT * from cFirstSQL WHERE NOT EXSISTS (SELECT * FROM cSecondSQL)
>
>I get not data, and there are differences.
Mark,
I don't know a practical way of doing this with just one SQL. But a small routine :
LPARAMETERS tcTable1, tcTable2
LOCAL lcGroupBy, ix
USE (tcTable1) in 0 again alias myAlias
lcGroupBy = ""
FOR ix = 1 to fcount("myAlias")
  lcGroupBy = lcGroupBy+iif(empty(lcGroupBy),"",",")+padl(ix,3,"0")
ENDFOR
USE in "myAlias"
SELECT * from (tcTable1) ;
  union all ;
  select * from (tcTable2) ;
  into cursor myCursor
SELECT * from myCursor ;
  having cnt(*)>1 ;
  group by &lcGroupBy ;
  into cursor crsDupRecs
BROW
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