Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Comparing two SQL cursors
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00239523
Message ID:
00239584
Views:
17
Sorry I haven't uses EXISTS before.

Todd caught something I had missed in the UNION command. By default it removes duplicates. That makes this entire task very easy if you instead want just the complete list of records with no duplications

SELECT * FROM c1 ;
UNION
SELECT * FROM c2 ;
INTO CURSOR c3

But if this isn't what you want, I think you will compare all of the fields.

> I have 30+ fields to validate .....
>
>Out of interest the SELECT * FROM ..... WHERE NOT EXISTS (SELECT ... FROM ...) only works with one primary field ?
>
>Regards
>Mark
>
>>You would need to do two select. First to find out what is in c1 and is not in c2 and the other way around. An example is below. Note: you need to compare each column.
>>
>>
>>SELECT * from c1 ;
>> WHERE c1.field1 <> c2.field2 AND ;
>>       c1.field2 <> c2.field2 AND ;
>>INTO CURSOR
>>
>>
>>Al alternative if what you really wanted was the two tables merged without any duplicates would be to UNION them together then do a GROUP BY on every field in the table. The result is all records from both tables without duplicates.
>>
>>>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.
Previous
Reply
Map
View

Click here to load this message in the networking platform