Thanks
evaluates to
False OR true
which is
true
You should use AND, instead of OR.
Alternatively:
"Vic" NOT IN( "Vic", "Pioneer", "Bud" )
Vanderghast, Access MVP
"Bjorgoal" <Bjor...@discussions.microsoft.com> wrote in message
news:C1909998-A5F7-43C8...@microsoft.com...
The LIKE operator is used *only* for searches using wildcards, to find partial
matches. If you don't have a * or # or ? or other wildcard character in the
criterion, then LIKE is functionally identical to =. In this case you don't
need LIKE at all!
Instead, use a criterion of
NOT IN ("Vic", "Pioneer", "Bud")
If the list of contractors to be excluded is extensive and/or subject to
change, then I'd suggest setting up an Excludes table with one row per
contractor to be excluded, and use the Unmatched Query Wizard to show all
records except those in the Excludes table.
John W. Vinson [MVP]
Regards
Jeff Boyce
Microsoft Office/Access MVP
"Bjorgoal" <Bjor...@discussions.microsoft.com> wrote in message
news:C1909998-A5F7-43C8...@microsoft.com...
HTH
Pieter
"Jeff Boyce" <nons...@nonsense.com> wrote in message
news:OI%23nvxVA...@TK2MSFTNGP04.phx.gbl...
>From an implementation point of view, the OP could have a SQL
PROCEDURE (parameter Query) with many parameters that have a default
value of NULL e.g. (ANSI-92 Query Mode):
CREATE PROCEDURE GetOrdersExcludeCustomers
(
arg_exclude_customerID_01 CHAR(5) = NULL,
arg_exclude_customerID_02 CHAR(5) = NULL,
arg_exclude_customerID_03 CHAR(5) = NULL,
arg_exclude_customerID_04 CHAR(5) = NULL,
arg_exclude_customerID_05 CHAR(5) = NULL,
arg_exclude_customerID_06 CHAR(5) = NULL,
arg_exclude_customerID_07 CHAR(5) = NULL,
arg_exclude_customerID_08 CHAR(5) = NULL,
arg_exclude_customerID_09 CHAR(5) = NULL,
arg_exclude_customerID_10 CHAR(5) = NULL,
arg_exclude_customerID_11 CHAR(5) = NULL,
arg_exclude_customerID_12 CHAR(5) = NULL,
arg_exclude_customerID_13 CHAR(5) = NULL,
arg_exclude_customerID_14 CHAR(5) = NULL,
arg_exclude_customerID_15 CHAR(5) = NULL
)
AS
SELECT CustomerID, OrderID, OrderDate
FROM Orders
WHERE CustomerID NOT IN (arg_exclude_customerID_01,
arg_exclude_customerID_02, arg_exclude_customerID_03,
arg_exclude_customerID_04, arg_exclude_customerID_05,
arg_exclude_customerID_06, arg_exclude_customerID_07,
arg_exclude_customerID_08, arg_exclude_customerID_09,
arg_exclude_customerID_10, arg_exclude_customerID_11,
arg_exclude_customerID_12, arg_exclude_customerID_13,
arg_exclude_customerID_14, arg_exclude_customerID_15);
The number of parameters in a proc is theoretically unlimited but the
practical upper limit, due to "query too complex" errors and the like,
is still quite high (approx two thousand). The Jet SQL Help (Access)
suggests the limit is 255: is this the officially supported limit or
merely another error with this document?
Jamie.
--
Example for Northwind. Usage e.g. (ANSI-92 Query Mode):
EXECUTE GetOrdersExcludeCustomers 'SAVEA', 'ANTON', 'HUNGO';
Jamie
--
If you try
? eval( " 4 NOT IN (1, 2, null) ")
-1
where -1 is to be read as "true" ( 0 being read as false). That is fine?
Well, that is not what the Standard requires, as long as I remember, since
the Standard will require the expression to evaluate to null, since
4 NOT IN (1, 2, null)
== 4 <> 1 AND 4 <> 2 AND 4 <> null
== true AND true AND null
== null
But that is NOT ALL the story...
On the other hand, Jet behaves that way ONLY FOR CONSTANT list, as
illustrated. Jet behaves like the Standard if the 'list" comes from a query:
.... WHERE 4 NOT IN (SELECT ... )
In that case, if the SELECT contains a NULL, the result of the NOT IN is
also NULL !
So, basically, yes, in Jet, that solution will work, but would it work with
MS SQL Server used as database engine? Note that I have NOT explicitly
checked that precise particular case, though.
Vanderghast, Access MVP
"Jamie Collins" <jamiec...@xsmail.com> wrote in message
news:1191242360....@n39g2000hsh.googlegroups.com...
You are correct, of course. I could post a SQL Server equivalent using
COALESCE to handle the NULL value but someone would point out it isn't
compliant with SQL/PSM ;-)
Jamie.
--