Field SELECT WHERE! = Value, how is this done in mysql?

I can not find the answer, since mysql NOT search in google is a nightmare (even with quotes).

I need to make a request like this:

SELECT * FROM table WHERE field=value AND field2!=value2 AND field3!=value3

How it's done? Is it possible?

+3
source share
4 answers
SELECT * FROM table WHERE 
        ((field = value) AND  
        (field2 <> value2) AND 
        (field3 <> value3))

If you are dealing with NULL, you need to do two things:

  • Use SET ANSI_NULLS ON
  • Declare values NULLfor a dummy value.

SQL Unable to compare zeros.

For this:

SET @value = ISNULL(@value, -1);
+6
source

Yes, you can do what you wrote, but use <>instead!=

, , ""? , 123 value 123; "foobar" value 'foobar'.

+4

Have you tried the operator <>

SELECT * FROM table WHERE field = value AND field2 <> value2
+4
source

Have you tried "<>"? he works at Delphi

+2
source

Source: https://habr.com/ru/post/1707038/


All Articles