user7195968
user7195968

Reputation:

Access query amazing

When I do that on access, SELECT RMonturesImp.N°Fac FROM RMonturesImp, Rpartielun WHERE NOT (RMonturesImp.N°Fac IN (1,2,5)) GROUP BY RMonturesImp.N°Fac;

but when I do this

SELECT RMonturesImp.N°Fac
FROM RMonturesImp, Rpartielun
WHERE NOT (RMonturesImp.N°Fac IN Requête2)
GROUP BY RMonturesImp.N°Fac;

it doesn't work (it shows 1,2,5 indeed) although the result of Requête2 (which is a query) is also (1,2,5). I can't understand this!

Thanks in advance

Upvotes: 0

Views: 31

Answers (1)

Gustav
Gustav

Reputation: 56026

It's quite easy. The IN (1,2,5)) must be explicit as SQL will not evaluate an expression not to say a function to obtain the values for IN.

So build your SQL in code creating the string, or pull the values from a (temp) table.

Try this:

SELECT RMonturesImp.N°Fac
FROM RMonturesImp, Rpartielun
WHERE RMonturesImp.N°Fac NOT IN (Select N°Fac From Requête2)
GROUP BY RMonturesImp.N°Fac;

Upvotes: 1

Related Questions