Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Record that doesn't exist in 2nd table
Message
From
26/07/2001 05:33:27
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
26/07/2001 04:12:38
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00535557
Message ID:
00535577
Views:
13
>Hi,
>I have a cursor called cursorA which is query from tableA. Now, I need to get the records from tableA which doesn't match the records collected in cusrorA with 2 conditions. I have try couples of way to do so such as, #, <>, !=, NOT (... == ...), or even NOT IN (...) AND NOT IN(...). All of these doesn't return correct result. any ideas?
>
>
>Example 1
>
>Select s.usize, s.uname, s.ppu, s.gcode, s.ccode, s.Ino, s.BCode, s.IName, .loccode, s.CPU, s.qty, (s.CPU * s.qty) AS TotalCost ;
>FROM tempStock1 s ;
>WHERE NOT s.Ino IN (SELECT Ino FROM csrLPQty) and ;
>NOT (s.loccode in (select loccode from csrLPQty))) ;
>UNION ;
>SELECT usize, uname, ppu, gcode, ccode, Ino, BCode, IName, loccode, CPU, qty, (CPU * qty) AS TotalCost ;
>FROM csrLPQty ;
>into cursor tempStock
>
>Example 2
>Select s.usize, s.uname, s.ppu, s.gcode, s.ccode, s.Ino, s.BCode, s.IName, s.loccode, s.CPU, s.qty, (s.CPU * s.qty) AS TotalCost ;
>FROM tempStock1 s, csrLPQty l ;
>WHERE (s.Ino <> l.INo AND s.LocCode <> l.LocCode) ;
>UNION ;
>SELECT usize, uname, ppu, gcode, ccode, Ino, BCode, IName, loccode, CPU, qty, (CPU * qty) AS TotalCost ;
>FROM csrLPQty ;
>into cursor tempStock
>
>
>I am not the most powerful man in this world.

John,
I suspect you're trying to do is what you want.
What you do means :
select all inos from csrLPQty to set1
select all loccodes from csrLPQty to set2
tempStock1 ino not exists in set1 and loccode not exists in set2 ? - yes, include

ie :
*Tempstock1
ino loccode
1   2 && ino doesn't but loccode exists
4   3 && ino exists
8   1 && ino and loccode exists - also within same record
9   2 && ino and loccode exists

*csrLPQty
ino loccode
5   2
4   7
8   1
9   1
First part of union would return no records causing all to be from csrLPQty. IOW it's interpreted as :

ino not in (4,5,8,9) and loccode not in (1,2,7)

I think what you want was first part to return all except '8,1' where ino and loccode match. If so you could say :
Select s.usize, s.uname, s.ppu, ;
   s.gcode, s.ccode, s.Ino, s.BCode, s.IName, ;
   s.loccode, s.CPU, s.qty, (s.CPU * s.qty) AS TotalCost ;
 FROM tempStock1 s ;
   WHERE bintoc(ino)+bintoc(loccode) NOT IN ;
   (SELECT bintoc(ino)+bintoc(loccode) FROM csrLPQty) ;
 UNION ;
 ...
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