Queries fail to filter out certain states even though specified in query (1 Viewer)

johnmerlino

Registered User.
Local time
Today, 01:26
Joined
Oct 14, 2010
Messages
81
Hey all,

This query fails to filter out states that aren't either FL or NY, even though I specify to do exactly that in the query:

Code:
SELECT contacts.id, contacts.names_1, contacts.names_2, contacts.addresses INTO PrepareForDuplicateCheck
FROM contacts, possibles
WHERE (INSTR(CONTACTS.NAMES_1, possibles.fullname) > 0)
Or
(INSTR(CONTACTS.NAMES_2, possibles.fullname) > 0) 
and
(
CONTACTS.us_states_and_canada = "FL"
or
CONTACTS.us_states_and_canada = "NY"
);

Thanks for any response.
 

the_net_2.0

Banned
Local time
Today, 03:26
Joined
Sep 6, 2010
Messages
812
you don't have the where clause properly nested:
WHERE (INSTR(CONTACTS.NAMES_1, possibles.fullname) > 0)

Or //THIS IS ON THE MAIN LEVEL

(INSTR(CONTACTS.NAMES_2, possibles.fullname) > 0)

and //THIS IS ALSO ON MAIN LEVEL

(CONTACTS.us_states_and_canada = "FL"

or //THIS COMPARISON IS NOT JOINED IN A MASTER PARENTHESIS

CONTACTS.us_states_and_canada = "NY");
[/code].

it is really unclear what you're getting at, but first maybe try:
Code:
WHERE ((INSTR(CONTACTS.NAMES_1, possibles.fullname) > 0)

Or 

((INSTR(CONTACTS.NAMES_2, possibles.fullname) > 0) 

and 

((CONTACTS.us_states_and_canada = "FL"

or

CONTACTS.us_states_and_canada = "NY"))));
 

Users who are viewing this thread

Top Bottom