I can't find the answer since searching mysql NOT in google is a nightmare (even with the quotes).
I need to make a query like this:
SELECT * FROM table WHERE field=value AND field2!=value2 AND field3!=value3
How it is done? Is it even possible?
I can't find the answer since searching mysql NOT in google is a nightmare (even with the quotes).
I need to make a query like this:
SELECT * FROM table WHERE field=value AND field2!=value2 AND field3!=value3
How it is done? Is it even possible?
Yes, you can do exactly what you wrote, but use <> instead of !=
Perhaps the answer depends on what "value" is? For example, for an integer 123 value would be 123; for a string "foobar" value would be 'foobar'.
SELECT * FROM table WHERE
((field = value) AND
(field2 <> value2) AND
(field3 <> value3))
If you're dealing with NULL, you have to do two things:
SET ANSI_NULLS ONNULL values to a dummy value. SQL Cannot compare nulls.
To do that:
SET @value = ISNULL(@value, -1);
have you tried the <> operator
SELECT * FROM table WHERE field = value AND field2 <> value2