Unable to fisue out simple sql [message #598535] |
Tue, 15 October 2013 12:16 |
|
DIPRINKS
Messages: 57 Registered: July 2013 Location: Michigan
|
Member |
|
|
Unable to figure out why this query results 0 records although there are records in the one table which doesnt exist in another table.
SELECT count(*)
FROM advance.primary_gift t
WHERE t.prim_gift_receipt_number NOT IN
(SELECT receipt_number
FROM advance.gift_tender_type)---0 records
SELECT *
FROM advance.primary_gift t where prim_gift_receipt_number in (0001088058,0001046163,0001046164,0001046170,0001046171)---5 records
SELECT *
FROM advance.gift_tender_type t where receipt_number=0001088058 in ('0001088058','0001046163','0001046164','0001046170','0001046171')---0 records
|
|
|
|
|
|
Re: Unable to fisue out simple sql [message #598552 is a reply to message #598546] |
Tue, 15 October 2013 13:33 |
|
Michel Cadot
Messages: 68645 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
Quote:the only difference is one is nullable and other is not.
But not the queries you show us:
0001088058,0001046163,0001046164,0001046170,0001046171
and
'0001088058','0001046163','0001046164','0001046170','0001046171'
One is numbers the other one is strings
When you convert number 0001088058 to string you have '1088058' not '0001088058'.
In the end, put a test case so we can reproduce what you have.
[Updated on: Tue, 15 October 2013 13:33] Report message to a moderator
|
|
|
|