>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 :
ino loccode
1 2
4 3
8 1
9 2
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