Help with sample query.

  • Thread starter Thread starter MN
  • Start date Start date
M

MN

Hi - I need to run a query to find out in a tableA field gender has some
other value than 1,2,3.
But this will product all records ! It was included 1,2,3,4,5...8,9.
If I using "AND" then it come out just records 4,5,6,7,8,9
Is it weird ? Thank you for any reply .

SELECT *
FROM TableA
WHERE gender<>1 OR gender <> 2 or gender<>3;
 
Thank for reply, actual value are: 1,2,3,4,88,99 And I want to see in this
field do they have a different value other than those number?
Regards,

KARL DEWEY said:
SELECT *
FROM TableA
WHERE [Gender] Not Between 1 AND 3;

--
Build a little, test a little.


MN said:
Hi - I need to run a query to find out in a tableA field gender has some
other value than 1,2,3.
But this will product all records ! It was included 1,2,3,4,5...8,9.
If I using "AND" then it come out just records 4,5,6,7,8,9
Is it weird ? Thank you for any reply .

SELECT *
FROM TableA
WHERE gender<>1 OR gender <> 2 or gender<>3;
 
I mean I like the AND than but the logical here somthing make me confused?
OK-The user want to print out all of record if the field gender have
diferent value other than 1,2,3,4,77,99 and you was right null is count too.

Thank you.
 
SELECT *
FROM TableA
WHERE ([Gender] Not Between 1 AND 3) AND ([Gender] <>88) AND ([Gender] <>99);

--
Build a little, test a little.


MN said:
Thank for reply, actual value are: 1,2,3,4,88,99 And I want to see in this
field do they have a different value other than those number?
Regards,

KARL DEWEY said:
SELECT *
FROM TableA
WHERE [Gender] Not Between 1 AND 3;

--
Build a little, test a little.


MN said:
Hi - I need to run a query to find out in a tableA field gender has some
other value than 1,2,3.
But this will product all records ! It was included 1,2,3,4,5...8,9.
If I using "AND" then it come out just records 4,5,6,7,8,9
Is it weird ? Thank you for any reply .

SELECT *
FROM TableA
WHERE gender<>1 OR gender <> 2 or gender<>3;
 
I do like this:

Select *
From tableA
WHERE ((gender Not Between 1 And 4) And (gender<>77) And (gender<>99)) Or
isnull(gender);

Thanks for any reply.

KARL DEWEY said:
SELECT *
FROM TableA
WHERE ([Gender] Not Between 1 AND 3) AND ([Gender] <>88) AND ([Gender] <>99);

--
Build a little, test a little.


MN said:
Thank for reply, actual value are: 1,2,3,4,88,99 And I want to see in this
field do they have a different value other than those number?
Regards,

KARL DEWEY said:
SELECT *
FROM TableA
WHERE [Gender] Not Between 1 AND 3;

--
Build a little, test a little.


:

Hi - I need to run a query to find out in a tableA field gender has some
other value than 1,2,3.
But this will product all records ! It was included 1,2,3,4,5...8,9.
If I using "AND" then it come out just records 4,5,6,7,8,9
Is it weird ? Thank you for any reply .

SELECT *
FROM TableA
WHERE gender<>1 OR gender <> 2 or gender<>3;
 
Thank for reply, actual value are: 1,2,3,4,88,99 And I want to see in this
field do they have a different value other than those number?

Gender NOT IN(1,2,3,4,88,99)

is a compact way to find records where there is a value in Gender (i.e. not
NULL) but exclude those six specific values.
 
Back
Top